Skip to content

Commit 0e2201b

Browse files
authored
Prioritize inline worlds, not external ones (#1358)
When multiple `path`s are used the `generate!` macro will fail if they all contain a `world` and no world is otherwise specified. This then additionally affected when using `inline` plus loading auxiliary WIT from a `paths` directory (either explicitly or the default `wit`). This commit switches the logic to prioritizing worlds in the `inline` block because if that's being specified it's pretty likely the exact one that wants to be used.
1 parent ecb620e commit 0e2201b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

crates/guest-rust/macro/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ fn parse_source(
266266
}
267267
}
268268
}
269+
pkgs.truncate(0);
269270
pkgs.push(resolve.push_group(UnresolvedPackageGroup::parse("macro-input", s)?)?);
270271
}
271272
Some(Source::Paths(p)) => parse(p)?,

crates/rust/tests/codegen.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,18 @@ mod multiple_paths {
1616
generate_all,
1717
});
1818
}
19+
20+
#[allow(unused)]
21+
mod inline_and_path {
22+
wit_bindgen::generate!({
23+
inline: r#"
24+
package test:paths;
25+
26+
world test {
27+
import test:inline-and-path/bar;
28+
}
29+
"#,
30+
path: ["tests/wit/path3"],
31+
generate_all,
32+
});
33+
}

0 commit comments

Comments
 (0)