Skip to content

Commit

Permalink
Merge pull request #1545 from infinity0/master
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton authored May 21, 2019
2 parents bc5f73e + 81fb2d9 commit 9b04fe9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions crates/macro-support/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ macro_rules! methods {
($(($name:ident $(($other:tt))*, $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 @@ -69,16 +70,32 @@ macro_rules! methods {
if used.get() {
continue
}
if !cfg!(feature = "strict-macro") {
// 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));
let mut errors = Vec::new();
for (used, attr) in self.attrs.iter() {
if used.get() {
continue
}
}
Diagnostic::from_vec(errors)
}
};

(@method $name:ident, $variant:ident(Span, String, Span)) => {
Expand Down

0 comments on commit 9b04fe9

Please sign in to comment.