diff --git a/crates/wit-parser/src/resolve/mod.rs b/crates/wit-parser/src/resolve/mod.rs index 00910eb81e..602225bac7 100644 --- a/crates/wit-parser/src/resolve/mod.rs +++ b/crates/wit-parser/src/resolve/mod.rs @@ -3839,9 +3839,12 @@ impl Remap { if !resolve .include_stability(&include.stability, pkg_id, include.span) .with_context(|| { + let world_name = match self.worlds[include.id.index()] { + Some(resolved_id) => resolve.worlds[resolved_id].name.as_str(), + None => "", + }; format!( - "failed to process feature gate for included world [{}] in package [{}]", - resolve.worlds[include.id].name.as_str(), + "failed to process feature gate for included world [{world_name}] in package [{}]", resolve.packages[*pkg_id].name ) })? diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit b/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit new file mode 100644 index 0000000000..4fd350ce5f --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit @@ -0,0 +1,12 @@ +package a:b; + +interface foo { + @unstable(feature = inactive) + type gated = u32; + + record r { + field-a: u32, + field-b: gated, + field-c: string, + } +} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit.result new file mode 100644 index 0000000000..d42d1a0fda --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-gate-record-field.wit.result @@ -0,0 +1,5 @@ +failed to update field `field-b`: found a reference to a type which is excluded due to its feature not being activated + --> tests/ui/parse-fail/bad-gate-record-field.wit:7:10 + | + 7 | record r { + | ^ \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit new file mode 100644 index 0000000000..1d97b6991c --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit @@ -0,0 +1,8 @@ +package test:invalid@0.1.0; + +world a {} + +world b { + @since(version = 0.2.0) + include a; +} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit.result new file mode 100644 index 0000000000..29c77118b5 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-include.wit.result @@ -0,0 +1,5 @@ +failed to process feature gate for included world [a] in package [test:invalid@0.1.0]: feature gate cannot reference unreleased version 0.2.0 of package [test:invalid@0.1.0] (current version 0.1.0) + --> tests/ui/parse-fail/bad-since-on-include.wit:7:11 + | + 7 | include a; + | ^ \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit new file mode 100644 index 0000000000..020bf4db71 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit @@ -0,0 +1,4 @@ +package test:invalid@0.1.0; + +@since(version = 0.2.0) +interface foo {} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit.result new file mode 100644 index 0000000000..92d008367e --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-interface.wit.result @@ -0,0 +1,5 @@ +failed to process feature gate for interface [foo] in package [test:invalid@0.1.0]: feature gate cannot reference unreleased version 0.2.0 of package [test:invalid@0.1.0] (current version 0.1.0) + --> tests/ui/parse-fail/bad-since-on-interface.wit:4:11 + | + 4 | interface foo {} + | ^-- \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit new file mode 100644 index 0000000000..3574abd3f9 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit @@ -0,0 +1,6 @@ +package test:invalid@0.1.0; + +interface foo { + @since(version = 0.2.0) + type t = u32; +} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit.result new file mode 100644 index 0000000000..98481f5a6b --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-type.wit.result @@ -0,0 +1,5 @@ +failed to process feature gate for type [t] in package [test:invalid@0.1.0]: feature gate cannot reference unreleased version 0.2.0 of package [test:invalid@0.1.0] (current version 0.1.0) + --> tests/ui/parse-fail/bad-since-on-type.wit:5:8 + | + 5 | type t = u32; + | ^ \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit new file mode 100644 index 0000000000..89d0aaea72 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit @@ -0,0 +1,6 @@ +package test:invalid@0.1.0; + +world w { + @since(version = 0.2.0) + import x: func(); +} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit.result new file mode 100644 index 0000000000..95f3fbd398 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world-import.wit.result @@ -0,0 +1,5 @@ +failed to process world item in `w`: feature gate cannot reference unreleased version 0.2.0 of package [test:invalid@0.1.0] (current version 0.1.0) + --> tests/ui/parse-fail/bad-since-on-world-import.wit:5:10 + | + 5 | import x: func(); + | ^ \ No newline at end of file diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit new file mode 100644 index 0000000000..74bc5b38b1 --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit @@ -0,0 +1,4 @@ +package test:invalid@0.1.0; + +@since(version = 0.2.0) +world w {} diff --git a/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit.result b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit.result new file mode 100644 index 0000000000..d3ee8274ac --- /dev/null +++ b/crates/wit-parser/tests/ui/parse-fail/bad-since-on-world.wit.result @@ -0,0 +1,5 @@ +failed to process feature gate for world [w] in package [test:invalid@0.1.0]: feature gate cannot reference unreleased version 0.2.0 of package [test:invalid@0.1.0] (current version 0.1.0) + --> tests/ui/parse-fail/bad-since-on-world.wit:4:7 + | + 4 | world w {} + | ^ \ No newline at end of file