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

@@ -9,7 +9,7 @@ doctest = false
harness = false
[dependencies]
wasm-bindgen = { path = "../../.." }
wasm-bindgen = { path = "../../..", features = ["strict-macro"] }
[dev-dependencies]
compiletest_rs = "0.3"

View File

@@ -0,0 +1,11 @@
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
impl A {
#[wasm_bindgen(method)]
#[wasm_bindgen(method)]
pub fn foo() {
}
}

View File

@@ -0,0 +1,14 @@
error: unused #[wasm_bindgen] attribute
--> $DIR/unused-attributes.rs:7:20
|
7 | #[wasm_bindgen(method)]
| ^^^^^^
error: unused #[wasm_bindgen] attribute
--> $DIR/unused-attributes.rs:8:20
|
8 | #[wasm_bindgen(method)]
| ^^^^^^
error: aborting due to 2 previous errors