Skip to content

Commit 4d88732

Browse files
authored
Fix no_std; upgrade hashmap_core. (bytecodealliance#98)
1 parent 4c27864 commit 4d88732

5 files changed

Lines changed: 20 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exclude = ["fuzz/**/*", "tests/**/*"]
1616
criterion = "0.2"
1717

1818
[dependencies.hashmap_core]
19-
version = "0.1.9"
19+
version = "0.1.10"
2020
optional = true
2121

2222
[badges]

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//! a data-structure using this library.
2525
2626
#![cfg_attr(not(feature = "std"), no_std)]
27-
#![cfg_attr(not(feature = "std"), feature(alloc))]
2827

2928
#[cfg(not(feature = "std"))]
3029
extern crate hashmap_core;
@@ -124,7 +123,7 @@ mod validator;
124123

125124
#[cfg(not(feature = "std"))]
126125
mod std {
127-
pub use alloc::{boxed, vec};
126+
pub use alloc::{boxed, string, vec};
128127
pub use core::*;
129128
pub mod collections {
130129
pub use hashmap_core::HashSet;

src/parser.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@ impl<'a> Parser<'a> {
269269
.original_position();
270270
}
271271
match self.section_reader {
272-
ParserSectionReader::CodeSectionReader(ref reader) => return reader.original_position(),
273-
ParserSectionReader::DataSectionReader(ref reader) => return reader.original_position(),
272+
ParserSectionReader::CodeSectionReader(ref reader) => {
273+
return reader.original_position()
274+
}
275+
ParserSectionReader::DataSectionReader(ref reader) => {
276+
return reader.original_position()
277+
}
274278
ParserSectionReader::ElementSectionReader(ref reader) => {
275279
return reader.original_position();
276280
}
@@ -292,8 +296,12 @@ impl<'a> Parser<'a> {
292296
ParserSectionReader::TableSectionReader(ref reader) => {
293297
return reader.original_position();
294298
}
295-
ParserSectionReader::TypeSectionReader(ref reader) => return reader.original_position(),
296-
ParserSectionReader::NameSectionReader(ref reader) => return reader.original_position(),
299+
ParserSectionReader::TypeSectionReader(ref reader) => {
300+
return reader.original_position()
301+
}
302+
ParserSectionReader::NameSectionReader(ref reader) => {
303+
return reader.original_position()
304+
}
297305
ParserSectionReader::LinkingSectionReader(ref reader) => {
298306
return reader.original_position();
299307
}

src/primitives.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
*/
1515

1616
use std::boxed::Box;
17-
use std::error::Error;
1817
use std::fmt;
1918
use std::result;
2019

20+
#[cfg(feature = "std")]
21+
use std::error::Error;
22+
2123
#[derive(Debug, Copy, Clone)]
2224
pub struct BinaryReaderError {
2325
pub message: &'static str,
@@ -26,6 +28,7 @@ pub struct BinaryReaderError {
2628

2729
pub type Result<T> = result::Result<T, BinaryReaderError>;
2830

31+
#[cfg(feature = "std")]
2932
impl Error for BinaryReaderError {}
3033

3134
impl fmt::Display for BinaryReaderError {

src/validator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::cmp::min;
1818
use std::collections::HashSet;
1919
use std::result;
2020
use std::str;
21+
use std::string::String;
2122
use std::vec::Vec;
2223

2324
use limits::{
@@ -2016,7 +2017,7 @@ impl<'a> ValidatingParser<'a> {
20162017
}
20172018
ParserState::ExportSectionEntry { field, kind, index } => {
20182019
self.validation_error = self.check_export_entry(field, kind, index).err();
2019-
self.exported_names.insert(field.to_string());
2020+
self.exported_names.insert(String::from(field));
20202021
}
20212022
ParserState::StartSectionEntry(func_index) => {
20222023
self.validation_error = self.check_start(func_index).err();

0 commit comments

Comments
 (0)