Skip to content

Commit b7bbcf5

Browse files
committed
Fix compat with current nightly
1 parent 6d5ebaf commit b7bbcf5

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

crates/backend/src/ast.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use proc_macro2::TokenTree;
12
use quote::{ToTokens, Tokens};
23
use shared;
34
use syn;
@@ -757,7 +758,16 @@ impl BindgenAttrs {
757758
Some(i) => i,
758759
None => return BindgenAttrs::default(),
759760
};
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")
761771
}
762772

763773
fn module(&self) -> Option<&str> {
@@ -859,11 +869,11 @@ impl BindgenAttrs {
859869
impl syn::synom::Synom for BindgenAttrs {
860870
named!(parse -> Self, alt!(
861871
do_parse!(
862-
opts: parens!(call!(
872+
opts: call!(
863873
syn::punctuated::Punctuated::<_, syn::token::Comma>::parse_terminated
864-
)) >>
874+
) >>
865875
(BindgenAttrs {
866-
attrs: opts.1.into_iter().collect(),
876+
attrs: opts.into_iter().collect(),
867877
})
868878
) => { |s| s }
869879
|

crates/backend/src/codegen.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ impl ToTokens for ast::Struct {
109109
(quote! {
110110
impl ::wasm_bindgen::describe::WasmDescribe for #name {
111111
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+
}
112119
use wasm_bindgen::describe::*;
113120
inform(RUST_STRUCT);
114121
inform(#name_len);
115122
#(inform(#name_chars);)*
116123
}
117124
}
118125

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-
126126
impl ::wasm_bindgen::convert::IntoWasmAbi for #name {
127127
type Abi = u32;
128128

0 commit comments

Comments
 (0)