Skip to content

Commit 8775f9b

Browse files
authored
Merge pull request #1720 from alexcrichton/update-syn
Upgrade to syn/quote 1.0
2 parents 1d0c333 + 45b4390 commit 8775f9b

File tree

13 files changed

+111
-99
lines changed

13 files changed

+111
-99
lines changed

crates/backend/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extra-traits = ["syn/extra-traits"]
1919
bumpalo = "2.1"
2020
lazy_static = "1.0.0"
2121
log = "0.4"
22-
proc-macro2 = "0.4.8"
23-
quote = '0.6'
24-
syn = { version = '0.15', features = ['full'] }
22+
proc-macro2 = "1.0"
23+
quote = '1.0'
24+
syn = { version = '1.0', features = ['full'] }
2525
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }

crates/backend/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub struct Function {
209209
pub name: String,
210210
pub name_span: Span,
211211
pub renamed_via_js_name: bool,
212-
pub arguments: Vec<syn::ArgCaptured>,
212+
pub arguments: Vec<syn::PatType>,
213213
pub ret: Option<syn::Type>,
214214
pub rust_attrs: Vec<syn::Attribute>,
215215
pub rust_vis: syn::Visibility,

crates/backend/src/codegen.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,16 @@ impl TryToTokens for ast::Export {
385385
},
386386
};
387387

388-
for (i, syn::ArgCaptured { ty, .. }) in self.function.arguments.iter().enumerate() {
388+
let mut argtys = Vec::new();
389+
for (i, arg) in self.function.arguments.iter().enumerate() {
390+
argtys.push(&arg.ty);
389391
let i = i + offset;
390392
let ident = Ident::new(&format!("arg{}", i), Span::call_site());
391-
match *ty {
393+
let ty = &arg.ty;
394+
match &*arg.ty {
392395
syn::Type::Reference(syn::TypeReference {
393396
mutability: Some(_),
394-
ref elem,
397+
elem,
395398
..
396399
}) => {
397400
args.push(quote! {
@@ -405,7 +408,7 @@ impl TryToTokens for ast::Export {
405408
let #ident = &mut *#ident;
406409
});
407410
}
408-
syn::Type::Reference(syn::TypeReference { ref elem, .. }) => {
411+
syn::Type::Reference(syn::TypeReference { elem, .. }) => {
409412
args.push(quote! {
410413
#ident: <#elem as wasm_bindgen::convert::RefFromWasmAbi>::Abi
411414
});
@@ -450,7 +453,6 @@ impl TryToTokens for ast::Export {
450453
<#syn_ret as WasmDescribe>::describe();
451454
};
452455
let nargs = self.function.arguments.len() as u32;
453-
let argtys = self.function.arguments.iter().map(|arg| &arg.ty);
454456
let attrs = &self.function.rust_attrs;
455457

456458
let start_check = if self.start {
@@ -874,8 +876,9 @@ impl TryToTokens for ast::ImportFunction {
874876
let mut arguments = Vec::new();
875877
let ret_ident = Ident::new("_ret", Span::call_site());
876878

877-
for (i, syn::ArgCaptured { pat, ty, .. }) in self.function.arguments.iter().enumerate() {
878-
let name = match pat {
879+
for (i, arg) in self.function.arguments.iter().enumerate() {
880+
let ty = &arg.ty;
881+
let name = match &*arg.pat {
879882
syn::Pat::Ident(syn::PatIdent {
880883
by_ref: None,
881884
ident,
@@ -884,7 +887,7 @@ impl TryToTokens for ast::ImportFunction {
884887
}) => ident.clone(),
885888
syn::Pat::Wild(_) => syn::Ident::new(&format!("__genarg_{}", i), Span::call_site()),
886889
_ => bail_span!(
887-
pat,
890+
arg.pat,
888891
"unsupported pattern in #[wasm_bindgen] imported function",
889892
),
890893
};

crates/backend/src/defined.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl ImportedTypes for syn::Path {
193193
seg.arguments.imported_types(f);
194194
}
195195
f(
196-
&self.segments.last().unwrap().value().ident,
196+
&self.segments.last().unwrap().ident,
197197
ImportedTypeKind::Reference,
198198
);
199199
}
@@ -272,12 +272,24 @@ impl ImportedTypes for ast::Function {
272272
}
273273
}
274274

275-
impl ImportedTypes for syn::ArgCaptured {
275+
impl ImportedTypes for syn::FnArg {
276276
fn imported_types<F>(&self, f: &mut F)
277277
where
278278
F: FnMut(&Ident, ImportedTypeKind),
279279
{
280-
self.ty.imported_types(f);
280+
match self {
281+
syn::FnArg::Receiver(_) => {}
282+
syn::FnArg::Typed(p) => p.imported_types(f),
283+
}
284+
}
285+
}
286+
287+
impl ImportedTypes for syn::PatType {
288+
fn imported_types<F>(&self, f: &mut F)
289+
where
290+
F: FnMut(&Ident, ImportedTypeKind),
291+
{
292+
self.ty.imported_types(f)
281293
}
282294
}
283295

crates/backend/src/encode.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,10 @@ fn shared_function<'a>(func: &'a ast::Function, _intern: &'a Interner) -> Functi
197197
.iter()
198198
.enumerate()
199199
.map(|(idx, arg)| {
200-
if let syn::Pat::Ident(ref x) = arg.pat {
201-
x.ident.to_string()
202-
} else {
203-
format!("arg{}", idx)
200+
if let syn::Pat::Ident(x) = &*arg.pat {
201+
return x.ident.to_string()
204202
}
203+
format!("arg{}", idx)
205204
})
206205
.collect::<Vec<_>>();
207206
Function {

crates/macro-support/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ extra-traits = ["syn/extra-traits"]
1717
strict-macro = []
1818

1919
[dependencies]
20-
syn = { version = '0.15.0', features = ['visit'] }
21-
quote = '0.6'
22-
proc-macro2 = "0.4.9"
20+
syn = { version = '1.0', features = ['visit'] }
21+
quote = '1.0'
22+
proc-macro2 = "1.0"
2323
wasm-bindgen-backend = { path = "../backend", version = "=0.2.48" }
2424
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }

0 commit comments

Comments
 (0)