Merge pull request #1550 from alexcrichton/more-better-errors

Improve diagnostics with missing trait implementations
This commit is contained in:
Alex Crichton
2019-05-20 13:04:46 -05:00
committed by GitHub
7 changed files with 106 additions and 36 deletions

View File

@@ -0,0 +1,9 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen]
pub fn foo() -> Result<JsValue, JsValue>;
}
fn main() {}

View File

@@ -0,0 +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:6:9
|
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`.