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:
Alex Crichton
2019-05-20 10:49:06 -07:00
parent a02d210d5c
commit 2cbb8b8a69
6 changed files with 68 additions and 9 deletions

View File

@ -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`.

View File

@ -0,0 +1,11 @@
use wasm_bindgen::prelude::*;
struct A;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen]
pub fn foo(a: A);
}
fn main() {}

View 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`.

View File

@ -0,0 +1,10 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen]
pub fn foo(a: A);
}
fn main() {}

View 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`.