mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 07:21:24 +00:00
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:
@ -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(),
|
||||
|
Reference in New Issue
Block a user