mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-18 23:41:24 +00:00
Improve diagnostics with missing trait implementations
Rejigger a few spans, work around an odd rustc issue, and hopefully produce higher quality error messages! Closes #1528
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
error[E0277]: the trait bound `std::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>: wasm_bindgen::convert::traits::FromWasmAbi` is not satisfied
|
||||
--> $DIR/missing-catch.rs:3:1
|
||||
--> $DIR/missing-catch.rs:6:9
|
||||
|
|
||||
3 | #[wasm_bindgen]
|
||||
| ^^^^^^^^^^^^^^^ the trait `wasm_bindgen::convert::traits::FromWasmAbi` is not implemented for `std::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>`
|
||||
6 | pub fn foo() -> Result<JsValue, JsValue>;
|
||||
| ^^^ the trait `wasm_bindgen::convert::traits::FromWasmAbi` is not implemented for `std::result::Result<wasm_bindgen::JsValue, wasm_bindgen::JsValue>`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
11
crates/macro/ui-tests/traits-not-implemented.rs
Normal file
11
crates/macro/ui-tests/traits-not-implemented.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
struct A;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen]
|
||||
pub fn foo(a: A);
|
||||
}
|
||||
|
||||
fn main() {}
|
7
crates/macro/ui-tests/traits-not-implemented.stderr
Normal file
7
crates/macro/ui-tests/traits-not-implemented.stderr
Normal file
@ -0,0 +1,7 @@
|
||||
error[E0277]: the trait bound `A: wasm_bindgen::convert::traits::IntoWasmAbi` is not satisfied
|
||||
--> $DIR/traits-not-implemented.rs:8:12
|
||||
|
|
||||
8 | pub fn foo(a: A);
|
||||
| ^^^ the trait `wasm_bindgen::convert::traits::IntoWasmAbi` is not implemented for `A`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
10
crates/macro/ui-tests/unknown-type-in-import.rs
Normal file
10
crates/macro/ui-tests/unknown-type-in-import.rs
Normal file
@ -0,0 +1,10 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen]
|
||||
pub fn foo(a: A);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
7
crates/macro/ui-tests/unknown-type-in-import.stderr
Normal file
7
crates/macro/ui-tests/unknown-type-in-import.stderr
Normal file
@ -0,0 +1,7 @@
|
||||
error[E0412]: cannot find type `A` in this scope
|
||||
--> $DIR/unknown-type-in-import.rs:6:19
|
||||
|
|
||||
6 | pub fn foo(a: A);
|
||||
| ^ not found in this scope
|
||||
|
||||
For more information about this error, try `rustc --explain E0412`.
|
Reference in New Issue
Block a user