File tree 4 files changed +26
-2
lines changed
4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 129
129
proc-macro.
130
130
[ #3601 ] ( https://github.com/rustwasm/wasm-bindgen/pull/3601 )
131
131
132
+ * Fix bug with function arguments coming from ` macro_rules! ` .
133
+ [ #3625 ] ( https://github.com/rustwasm/wasm-bindgen/pull/3625 )
134
+
132
135
### Removed
133
136
134
137
* Removed ` ReadableStreamByobReader::read_with_u8_array() ` because it doesn't work with Wasm.
Original file line number Diff line number Diff line change @@ -523,8 +523,16 @@ impl TryToTokens for ast::Export {
523
523
argtys. push ( & * arg. ty ) ;
524
524
let i = i + offset;
525
525
let ident = Ident :: new ( & format ! ( "arg{}" , i) , Span :: call_site ( ) ) ;
526
- let ty = & arg. ty ;
527
- match & * arg. ty {
526
+ fn unwrap_nested_types ( ty : & syn:: Type ) -> & syn:: Type {
527
+ match & ty {
528
+ syn:: Type :: Group ( syn:: TypeGroup { ref elem, .. } ) => unwrap_nested_types ( elem) ,
529
+ syn:: Type :: Paren ( syn:: TypeParen { ref elem, .. } ) => unwrap_nested_types ( elem) ,
530
+ _ => ty,
531
+ }
532
+ }
533
+ let ty = unwrap_nested_types ( & arg. ty ) ;
534
+
535
+ match & ty {
528
536
syn:: Type :: Reference ( syn:: TypeReference {
529
537
mutability : Some ( _) ,
530
538
elem,
Original file line number Diff line number Diff line change
1
+ //! This tests that the `wasm_bindgen` macro produces code that compiles for this use case.
2
+ //! `cargo test --target wasm32-unknown-unknown` will not run if this test breaks.
3
+ use wasm_bindgen:: prelude:: * ;
4
+
5
+ macro_rules! my_export {
6
+ ( $i: ident, $s: ty) => {
7
+ #[ wasm_bindgen]
8
+ pub fn $i( _: $s) { }
9
+ } ;
10
+ }
11
+
12
+ my_export ! ( should_compile, & [ i32 ] ) ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ pub mod js_keywords;
35
35
pub mod js_objects;
36
36
pub mod jscast;
37
37
pub mod link_to;
38
+ pub mod macro_rules;
38
39
pub mod math;
39
40
pub mod no_shims;
40
41
pub mod node;
You can’t perform that action at this time.
0 commit comments