Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit cdf44f4

Browse files
chore: don't require nightly for no_std
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
1 parent abdfb74 commit cdf44f4

File tree

7 files changed

+18
-24
lines changed

7 files changed

+18
-24
lines changed

crates/parser/src/conversion.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,12 @@ pub(crate) fn convert_memarg(memarg: wasmparser::MemArg) -> MemArg {
113113
}
114114

115115
pub fn process_operators<'a>(
116-
offset: usize,
116+
mut offset: usize,
117117
ops: impl Iterator<Item = Result<wasmparser::Operator<'a>, wasmparser::BinaryReaderError>>,
118118
mut validator: FuncValidator<ValidatorResources>,
119119
) -> Result<Box<[Instruction]>> {
120120
let mut instructions = Vec::new();
121121

122-
let mut offset = offset.into();
123122
for op in ops {
124123
let op = op?;
125124
validator.op(offset, &op)?;

crates/tinywasm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ default=["std", "parser", "logging"]
2727
logging=["log", "tinywasm-types/logging", "tinywasm-parser?/logging"]
2828
std=["tinywasm-parser?/std", "tinywasm-types/std"]
2929
parser=["tinywasm-parser"]
30-
nightly=[]

crates/tinywasm/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl Display for Error {
7171
}
7272
}
7373

74+
#[cfg(any(feature = "std", all(not(feature = "std"), nightly)))]
7475
impl crate::std::error::Error for Error {}
7576

7677
#[cfg(feature = "parser")]

crates/tinywasm/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99
))]
1010
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms, unreachable_pub)]
11-
#![cfg_attr(feature = "nightly", feature(error_in_core))]
11+
#![cfg_attr(nightly, feature(error_in_core))]
1212

1313
//! A tiny WebAssembly Runtime written in Rust
1414
//!
@@ -56,14 +56,11 @@
5656
//! - `parser` (default): Enables the `tinywasm_parser` crate for parsing WebAssembly modules.
5757
//!
5858
//! ## No-std support
59-
//! TinyWasm supports `no_std` environments by disabling the `std` feature. This removes
60-
//! support for parsing from files and streams, but otherwise the API is the same.
61-
//! Additionally, you must use a nightly compiler as TinyWasm uses the `error_in_core` feature
62-
//! and have a `GlobalAlloc` implementation for allocating memory.
63-
64-
// compiler error when using no_std without nightly
65-
#[cfg(all(not(feature = "std"), not(nightly)))]
66-
const _: () = { compile_error!("`nightly` feature is required for `no_std`") };
59+
//! TinyWasm supports `no_std` environments by disabling the `std` feature and registering
60+
//! a custom allocator. This removes support for parsing from files and streams,
61+
//! but otherwise the API is the same.
62+
//!
63+
//! Additionally, if you want proper error types, you must use a `nightly` compiler.
6764
6865
mod std;
6966
extern crate alloc;

crates/tinywasm/src/std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ pub(crate) mod error {
1313
#[cfg(feature = "std")]
1414
pub(crate) use std::error::Error;
1515

16-
#[cfg(not(feature = "std"))]
16+
#[cfg(all(not(feature = "std"), nightly))]
1717
pub(crate) use core::error::Error;
1818
}

crates/tinywasm/tests/mvp.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ fn parse_module(mut module: wast::core::Module) -> Result<TinyWasmModule, Error>
1818

1919
#[test]
2020
#[ignore]
21-
fn test_mvp() {
21+
fn test_mvp() -> Result<()> {
2222
let mut test_suite = TestSuite::new();
2323

2424
wasm_testsuite::MVP_TESTS.iter().for_each(|group| {
25-
println!("test: {}", group);
26-
2725
let test_group = test_suite.test_group(group);
2826

2927
let wast = wasm_testsuite::get_test_wast(group).expect("failed to get test wast");
@@ -59,11 +57,9 @@ fn test_mvp() {
5957
AssertMalformed {
6058
span,
6159
module: QuoteWat::Wat(wast::Wat::Module(module)),
62-
message,
60+
message: _,
6361
} => {
64-
println!(" assert_malformed: {}", message);
6562
let res = std::panic::catch_unwind(|| parse_module(module).map(|_| ()));
66-
6763
test_group.add_result(
6864
&format!("{}-malformed", name),
6965
span,
@@ -85,9 +81,11 @@ fn test_mvp() {
8581
});
8682

8783
if test_suite.failed() {
88-
panic!("failed one or more tests: {:#?}", test_suite);
84+
eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
85+
Err(Error::Other("failed one or more tests".to_string()))
8986
} else {
90-
println!("passed all tests: {:#?}", test_suite);
87+
println!("\n\npassed all tests:\n{:#?}", test_suite);
88+
Ok(())
9189
}
9290
}
9391

@@ -169,11 +167,11 @@ impl TestGroup {
169167
}
170168

171169
fn add_result(&mut self, name: &str, span: wast::token::Span, result: Result<()>) {
172-
self.tests.insert(name.to_string(), TestCase { result, span });
170+
self.tests.insert(name.to_string(), TestCase { result, _span: span });
173171
}
174172
}
175173

176174
struct TestCase {
177175
result: Result<()>,
178-
span: wast::token::Span,
176+
_span: wast::token::Span,
179177
}

crates/wasm-testsuite/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub const V2_DRAFT_1_TESTS: &[&str] = &["address.wast","align.wast","binary-leb1
3939

4040
/// Get all test file names and their contents.
4141
pub fn get_tests_wast(include_proposals: &[String]) -> impl Iterator<Item = (String, Cow<'static, [u8]>)> {
42-
get_tests(&include_proposals)
42+
get_tests(include_proposals)
4343
.filter_map(|name| Some((name.clone(), get_test_wast(&name)?)))
4444
.map(|(name, data)| (name, Cow::Owned(data.to_vec())))
4545
}

0 commit comments

Comments
 (0)