Assert all attributes are used by default

This commit implements a system that will assert that all
`#[wasm_bindgen]` attributes are actually used during compilation. This
should help ensure that we don't sneak in stray attributes that don't
actually end up having any meaning, and hopefully make it a bit easier
to learn `#[wasm_bindgen]`!
This commit is contained in:
Alex Crichton
2018-11-27 15:14:59 -08:00
parent e3b628689f
commit c8a352189b
11 changed files with 355 additions and 361 deletions

View File

@ -5,7 +5,7 @@ use syn::parse::Error;
#[macro_export]
macro_rules! err_span {
($span:expr, $($msg:tt)*) => (
$crate::Diagnostic::span_error(&$span, format!($($msg)*))
$crate::Diagnostic::spanned_error(&$span, format!($($msg)*))
)
}
@ -43,7 +43,16 @@ impl Diagnostic {
}
}
pub fn span_error<T: Into<String>>(node: &ToTokens, text: T) -> Diagnostic {
pub fn span_error<T: Into<String>>(span: Span, text: T) -> Diagnostic {
Diagnostic {
inner: Repr::Single {
text: text.into(),
span: Some((span, span)),
},
}
}
pub fn spanned_error<T: Into<String>>(node: &ToTokens, text: T) -> Diagnostic {
Diagnostic {
inner: Repr::Single {
text: text.into(),