(&self, runner: &Runner, verify: &Verify<'_>)
| 223 | } |
| 224 | |
| 225 | fn verify(&self, runner: &Runner, verify: &Verify<'_>) -> Result<()> { |
| 226 | let bindings = verify |
| 227 | .bindings_dir |
| 228 | .join(format!("{}.rs", verify.world.to_snake_case())); |
| 229 | let test_edition = |edition: Edition| -> Result<()> { |
| 230 | let mut cmd = runner.rustc(edition); |
| 231 | cmd.arg(&bindings) |
| 232 | .arg("--crate-type=rlib") |
| 233 | .arg("-o") |
| 234 | .arg(verify.artifacts_dir.join("tmp")); |
| 235 | runner.run_command(&mut cmd)?; |
| 236 | Ok(()) |
| 237 | }; |
| 238 | |
| 239 | test_edition(Edition::E2021)?; |
| 240 | test_edition(Edition::E2024)?; |
| 241 | |
| 242 | // If bindings are generated in `#![no_std]` mode then verify that it |
| 243 | // compiles as such. |
| 244 | if verify.args.iter().any(|s| s == "--std-feature") { |
| 245 | let no_std_root = verify.artifacts_dir.join("no_std.rs"); |
| 246 | super::write_if_different( |
| 247 | &no_std_root, |
| 248 | r#" |
| 249 | #![no_std] |
| 250 | include!(env!("BINDINGS")); |
| 251 | |
| 252 | // This empty module named 'core' is here to catch module path |
| 253 | // conflicts with 'core' modules used in code generated by the |
| 254 | // wit_bindgen::generate macro. |
| 255 | // Ref: https://github.com/bytecodealliance/wit-bindgen/pull/568 |
| 256 | mod core {} |
| 257 | "#, |
| 258 | )?; |
| 259 | let mut cmd = runner.rustc(Edition::E2021); |
| 260 | cmd.arg(&no_std_root) |
| 261 | .env("BINDINGS", &bindings) |
| 262 | .arg("--crate-type=rlib") |
| 263 | .arg("-o") |
| 264 | .arg(verify.artifacts_dir.join("tmp")); |
| 265 | runner.run_command(&mut cmd)?; |
| 266 | } |
| 267 | Ok(()) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | enum Edition { |
nothing calls this directly
no test coverage detected