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

Enforce strict attribute checking #3070

Closed
wants to merge 1 commit into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions crates/macro-support/src/parser.rs
Expand Up @@ -94,7 +94,6 @@ macro_rules! methods {
($(($name:ident, $variant:ident($($contents:tt)*)),)*) => {
$(methods!(@method $name, $variant($($contents)*));)*

#[cfg(feature = "strict-macro")]
fn check_used(self) -> Result<(), Diagnostic> {
// Account for the fact this method was called
ATTRS.with(|state| state.checks.set(state.checks.get() + 1));
Expand All @@ -104,26 +103,13 @@ macro_rules! methods {
if used.get() {
continue
}
// The check below causes rustc to crash on powerpc64 platforms
// with an LLVM error. To avoid this, we instead use #[cfg()]
// and duplicate the function below. See #58516 for details.
/*if !cfg!(feature = "strict-macro") {
continue
}*/
let span = match attr {
$(BindgenAttr::$variant(span, ..) => span,)*
};
errors.push(Diagnostic::span_error(*span, "unused #[wasm_bindgen] attribute"));
}
Diagnostic::from_vec(errors)
}

#[cfg(not(feature = "strict-macro"))]
fn check_used(self) -> Result<(), Diagnostic> {
// Account for the fact this method was called
ATTRS.with(|state| state.checks.set(state.checks.get() + 1));
Ok(())
}
};

(@method $name:ident, $variant:ident(Span, String, Span)) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/macro/Cargo.toml
Expand Up @@ -25,5 +25,5 @@ quote = "1.0"

[dev-dependencies]
trybuild = "1.0"
wasm-bindgen = { path = "../..", version = "0.2.82", features = ['strict-macro'] }
wasm-bindgen = { path = "../..", version = "0.2.82" }
wasm-bindgen-futures = { path = "../futures", version = "0.4.32" }