Result-ify src/parser.rs (#608)

* 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!
This commit is contained in:
Alex Crichton
2018-08-01 18:59:59 -05:00
committed by GitHub
parent d90802a40c
commit bdec2582aa
14 changed files with 667 additions and 137 deletions

View File

@@ -1,10 +1,8 @@
error: custom attribute panicked
--> $DIR/non-public-function.rs:7:1
error: can only #[wasm_bindgen] public functions
--> $DIR/non-public-function.rs:8:1
|
7 | #[wasm_bindgen]
| ^^^^^^^^^^^^^^^
|
= help: message: can only bindgen public functions
8 | fn foo() {}
| ^^^^^^^^^^^
error: aborting due to previous error