mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-28 04:22:38 +03:00
bdec2582aa
* 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!
44 lines
542 B
Rust
44 lines
542 B
Rust
#![feature(use_extern_macros)]
|
|
|
|
extern crate wasm_bindgen;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub struct A;
|
|
|
|
#[wasm_bindgen]
|
|
default impl A {
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
unsafe impl A {
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
impl Clone for A {
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
impl<T> A {
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
impl &'static A {
|
|
}
|
|
|
|
macro_rules! x { () => () }
|
|
|
|
#[wasm_bindgen]
|
|
impl A {
|
|
const X: u32 = 3;
|
|
type Y = u32;
|
|
x!();
|
|
|
|
// pub default fn foo() {} // TODO: compiler's pretty printer totally broken
|
|
|
|
|
|
pub const fn foo() {}
|
|
pub unsafe fn foo() {}
|
|
}
|