Catch more errors on non-wasm32 platforms

This commit tweaks the codegen for imported functions and such (anything
that relies on some imported intrinsic or function filled in by the CLI)
to share as much code as possible on non-wasm32 platforms. This should
help us catch more errors before compiling to wasm and also just make it
easier to write UI tests!

For example a UI test previously couldn't be written for #1528 but now
it can be, and one is include (although the error message is quite bad).
This commit is contained in:
Alex Crichton
2019-05-20 10:16:25 -07:00
parent f23b867179
commit a02d210d5c
3 changed files with 41 additions and 30 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:3:1
|
3 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^ 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`.