Skip to content

Commit 1f4ab0f

Browse files
authored
Fix includes of WIT source files to be bytes (#838)
Instead of using `include_str!` use `include_bytes!` since the inputs may now be in the wasm binary format instead of source file in utf-8.
1 parent 3faf486 commit 1f4ab0f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rust-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "wit-bindgen-rust-macro"
33
authors = ["Alex Crichton <alex@alexcrichton.com>"]
4-
version = "0.18.0"
4+
version = "0.18.1"
55
edition.workspace = true
66
repository = 'https://github.com/bytecodealliance/wit-bindgen'
77
license = "Apache-2.0 WITH LLVM-exception"

crates/rust-macro/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,16 @@ impl Config {
176176
}
177177
let mut contents = src.parse::<TokenStream>().unwrap();
178178

179-
// Include a dummy `include_str!` for any files we read so rustc knows that
179+
// Include a dummy `include_bytes!` for any files we read so rustc knows that
180180
// we depend on the contents of those files.
181181
for file in self.files.iter() {
182182
contents.extend(
183-
format!("const _: &str = include_str!(r#\"{}\"#);\n", file.display())
184-
.parse::<TokenStream>()
185-
.unwrap(),
183+
format!(
184+
"const _: &[u8] = include_bytes!(r#\"{}\"#);\n",
185+
file.display()
186+
)
187+
.parse::<TokenStream>()
188+
.unwrap(),
186189
);
187190
}
188191

0 commit comments

Comments
 (0)