mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-28 12:32:37 +03:00
bdec2582aa
* Make ConvertToAst trait fallible It's got some panics, and we'll be switching those to errors! * First example of a diagnostic-driven error Add a diagnostic-driven error `#[wasm_bindgen]` being attached to public functions, and add some macros to boot to make it easier to generate errors! * Result-ify `src/parser.rs` This commit converts all of `src/parser.rs` away from panics to using `Diagnostic` instead. Along the way this adds a test case per changed `panic!`, ensuring that we don't regress in these areas!
69 lines
1.6 KiB
Plaintext
69 lines
1.6 KiB
Plaintext
error: can only #[wasm_bindgen] public functions
|
|
--> $DIR/invalid-items.rs:8:1
|
|
|
|
|
8 | fn foo() {}
|
|
| ^^^^^^^^^^^
|
|
|
|
error: can only #[wasm_bindgen] safe functions
|
|
--> $DIR/invalid-items.rs:11:5
|
|
|
|
|
11 | pub unsafe fn foo1() {}
|
|
| ^^^^^^
|
|
|
|
error: can only #[wasm_bindgen] non-const functions
|
|
--> $DIR/invalid-items.rs:14:5
|
|
|
|
|
14 | pub const fn foo2() {}
|
|
| ^^^^^
|
|
|
|
error: structs with #[wasm_bindgen] cannot have lifetime or type parameters currently
|
|
--> $DIR/invalid-items.rs:17:11
|
|
|
|
|
17 | struct Foo<T>(T);
|
|
| ^^^
|
|
|
|
error: cannot import mutable globals yet
|
|
--> $DIR/invalid-items.rs:21:12
|
|
|
|
|
21 | static mut FOO: u32;
|
|
| ^^^
|
|
|
|
error: can't #[wasm_bindgen] variadic functions
|
|
--> $DIR/invalid-items.rs:23:25
|
|
|
|
|
23 | pub fn foo3(x: i32, ...);
|
|
| ^^^
|
|
|
|
error: only foreign mods with the `C` ABI are allowed
|
|
--> $DIR/invalid-items.rs:27:8
|
|
|
|
|
27 | extern "system" {
|
|
| ^^^^^^^^
|
|
|
|
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
|
--> $DIR/invalid-items.rs:31:12
|
|
|
|
|
31 | pub fn foo4<T>() {}
|
|
| ^^^
|
|
|
|
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
|
--> $DIR/invalid-items.rs:33:12
|
|
|
|
|
33 | pub fn foo5<'a>() {}
|
|
| ^^^^
|
|
|
|
error: can't #[wasm_bindgen] functions with lifetime or type parameters
|
|
--> $DIR/invalid-items.rs:35:12
|
|
|
|
|
35 | pub fn foo6<'a, T>() {}
|
|
| ^^^^^^^
|
|
|
|
error: #[wasm_bindgen] can only be applied to a function, struct, enum, impl, or extern block
|
|
--> $DIR/invalid-items.rs:38:1
|
|
|
|
|
38 | trait X {}
|
|
| ^^^^^^^^^^
|
|
|
|
error: aborting due to 11 previous errors
|
|
|