mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-30 19:41:56 +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:
@@ -9,7 +9,7 @@ doctest = false
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = { path = "../../.." }
|
||||
wasm-bindgen = { path = "../../..", features = ["strict-macro"] }
|
||||
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "0.3"
|
||||
|
11
crates/macro/ui-tests/unused-attributes.rs
Normal file
11
crates/macro/ui-tests/unused-attributes.rs
Normal 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() {
|
||||
}
|
||||
}
|
14
crates/macro/ui-tests/unused-attributes.stderr
Normal file
14
crates/macro/ui-tests/unused-attributes.stderr
Normal 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
|
||||
|
Reference in New Issue
Block a user