Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test to help track wasm features over time #131526

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)] =
Expand Down
41 changes: 41 additions & 0 deletions tests/ui/wasm/default-enabled-features.rs
Original file line number Diff line number Diff line change
@@ -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.
"
);
}
Loading