diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index e92366d5c5c3f..496f2e660abff 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -427,6 +427,13 @@ const WASM_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("sign-ext", Stable, &[]), ("simd128", Stable, &[]), // tidy-alphabetical-end + // + // Note that if a new feature is added above please add it to the test at + // tests/ui/wasm/default-enabled-features.rs to ensure that its + // on-by-default state is tracked over time. If you'd also be so kind as to + // update the reference, such as in + // https://github.com/rust-lang/reference/pull/1638, it would also be much + // appreciated. ]; const BPF_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = diff --git a/tests/ui/wasm/default-enabled-features.rs b/tests/ui/wasm/default-enabled-features.rs new file mode 100644 index 0000000000000..ec5c0edf49e00 --- /dev/null +++ b/tests/ui/wasm/default-enabled-features.rs @@ -0,0 +1,41 @@ +//@ only-wasm32 +//@ build-pass + +#![feature(wasm_target_feature)] + +fn main() { + #[cfg(any( + // on-by-default features + not(target_feature = "multivalue"), + not(target_feature = "mutable-globals"), + not(target_feature = "reference-types"), + not(target_feature = "sign-ext"), + + // off-by-default features + target_feature = "atomics", + target_feature = "bulk-memory", + target_feature = "exception-handling", + target_feature = "extended-const", + target_feature = "nontrapping-fptoint", + target_feature = "simd128", + target_feature = "relaxed-simd", + ))] + compile_error!( + "\ +If this test fails to compile then it means that the default set of features +active on WebAssembly targets is no longer what it used to be. This is likely +due to LLVM being updated and changing the definition of the `generic` CPU in +wasm. + +If you'd be so obliged please update the feature listings above this error +message. Additionally please update this file too: + +* src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md + +Specifically the section about \"Enabled WebAssembly features\". If you'd also +be so kind as to ping wasm maintainers and/or the release team in the PR that +updates this test it would also be much appreciated to ensure that this change +is communicated out to users. +" + ); +}