File tree 2 files changed +21
-11
lines changed 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change
1
+ use proc_macro2:: TokenTree ;
1
2
use quote:: { ToTokens , Tokens } ;
2
3
use shared;
3
4
use syn;
@@ -757,7 +758,16 @@ impl BindgenAttrs {
757
758
Some ( i) => i,
758
759
None => return BindgenAttrs :: default ( ) ,
759
760
} ;
760
- syn:: parse ( attrs. remove ( pos) . tts . into ( ) ) . expect ( "malformed #[wasm_bindgen] attribute" )
761
+ let mut tts = attrs. remove ( pos) . tts . into_iter ( ) ;
762
+ let tt = match tts. next ( ) {
763
+ Some ( TokenTree :: Group ( d) ) => d. stream ( ) ,
764
+ Some ( _) => panic ! ( "malformed #[wasm_bindgen] attribute" ) ,
765
+ None => return BindgenAttrs :: default ( ) ,
766
+ } ;
767
+ if tts. next ( ) . is_some ( ) {
768
+ panic ! ( "malformed #[wasm_bindgen] attribute" ) ;
769
+ }
770
+ syn:: parse ( tt. into ( ) ) . expect ( "malformed #[wasm_bindgen] attribute" )
761
771
}
762
772
763
773
fn module ( & self ) -> Option < & str > {
@@ -859,11 +869,11 @@ impl BindgenAttrs {
859
869
impl syn:: synom:: Synom for BindgenAttrs {
860
870
named ! ( parse -> Self , alt!(
861
871
do_parse!(
862
- opts: parens! ( call!(
872
+ opts: call!(
863
873
syn:: punctuated:: Punctuated :: <_, syn:: token:: Comma >:: parse_terminated
864
- ) ) >>
874
+ ) >>
865
875
( BindgenAttrs {
866
- attrs: opts. 1 . into_iter( ) . collect( ) ,
876
+ attrs: opts. into_iter( ) . collect( ) ,
867
877
} )
868
878
) => { |s| s }
869
879
|
Original file line number Diff line number Diff line change @@ -109,20 +109,20 @@ impl ToTokens for ast::Struct {
109
109
( quote ! {
110
110
impl :: wasm_bindgen:: describe:: WasmDescribe for #name {
111
111
fn describe( ) {
112
+ use wasm_bindgen:: __wbindgen_if_not_std;
113
+ __wbindgen_if_not_std! {
114
+ compile_error! {
115
+ "exporting a class to JS requires the `std` feature to \
116
+ be enabled in the `wasm-bindgen` crate"
117
+ }
118
+ }
112
119
use wasm_bindgen:: describe:: * ;
113
120
inform( RUST_STRUCT ) ;
114
121
inform( #name_len) ;
115
122
#( inform( #name_chars) ; ) *
116
123
}
117
124
}
118
125
119
- :: wasm_bindgen:: __wbindgen_if_not_std! {
120
- compile_error! {
121
- "exporting a class to JS requires the `std` feature to \
122
- be enabled in the `wasm-bindgen` crate"
123
- }
124
- }
125
-
126
126
impl :: wasm_bindgen:: convert:: IntoWasmAbi for #name {
127
127
type Abi = u32 ;
128
128
You can’t perform that action at this time.
0 commit comments