mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 21:11:22 +00:00
Upgrade to syn/quote 1.0
Fresh off the presses let's start the update!
This commit is contained in:
@ -209,7 +209,7 @@ pub struct Function {
|
||||
pub name: String,
|
||||
pub name_span: Span,
|
||||
pub renamed_via_js_name: bool,
|
||||
pub arguments: Vec<syn::ArgCaptured>,
|
||||
pub arguments: Vec<syn::PatType>,
|
||||
pub ret: Option<syn::Type>,
|
||||
pub rust_attrs: Vec<syn::Attribute>,
|
||||
pub rust_vis: syn::Visibility,
|
||||
|
@ -385,13 +385,16 @@ impl TryToTokens for ast::Export {
|
||||
},
|
||||
};
|
||||
|
||||
for (i, syn::ArgCaptured { ty, .. }) in self.function.arguments.iter().enumerate() {
|
||||
let mut argtys = Vec::new();
|
||||
for (i, arg) in self.function.arguments.iter().enumerate() {
|
||||
argtys.push(&arg.ty);
|
||||
let i = i + offset;
|
||||
let ident = Ident::new(&format!("arg{}", i), Span::call_site());
|
||||
match *ty {
|
||||
let ty = &arg.ty;
|
||||
match &*arg.ty {
|
||||
syn::Type::Reference(syn::TypeReference {
|
||||
mutability: Some(_),
|
||||
ref elem,
|
||||
elem,
|
||||
..
|
||||
}) => {
|
||||
args.push(quote! {
|
||||
@ -405,7 +408,7 @@ impl TryToTokens for ast::Export {
|
||||
let #ident = &mut *#ident;
|
||||
});
|
||||
}
|
||||
syn::Type::Reference(syn::TypeReference { ref elem, .. }) => {
|
||||
syn::Type::Reference(syn::TypeReference { elem, .. }) => {
|
||||
args.push(quote! {
|
||||
#ident: <#elem as wasm_bindgen::convert::RefFromWasmAbi>::Abi
|
||||
});
|
||||
@ -450,7 +453,6 @@ impl TryToTokens for ast::Export {
|
||||
<#syn_ret as WasmDescribe>::describe();
|
||||
};
|
||||
let nargs = self.function.arguments.len() as u32;
|
||||
let argtys = self.function.arguments.iter().map(|arg| &arg.ty);
|
||||
let attrs = &self.function.rust_attrs;
|
||||
|
||||
let start_check = if self.start {
|
||||
@ -874,8 +876,9 @@ impl TryToTokens for ast::ImportFunction {
|
||||
let mut arguments = Vec::new();
|
||||
let ret_ident = Ident::new("_ret", Span::call_site());
|
||||
|
||||
for (i, syn::ArgCaptured { pat, ty, .. }) in self.function.arguments.iter().enumerate() {
|
||||
let name = match pat {
|
||||
for (i, arg) in self.function.arguments.iter().enumerate() {
|
||||
let ty = &arg.ty;
|
||||
let name = match &*arg.pat {
|
||||
syn::Pat::Ident(syn::PatIdent {
|
||||
by_ref: None,
|
||||
ident,
|
||||
@ -884,7 +887,7 @@ impl TryToTokens for ast::ImportFunction {
|
||||
}) => ident.clone(),
|
||||
syn::Pat::Wild(_) => syn::Ident::new(&format!("__genarg_{}", i), Span::call_site()),
|
||||
_ => bail_span!(
|
||||
pat,
|
||||
arg.pat,
|
||||
"unsupported pattern in #[wasm_bindgen] imported function",
|
||||
),
|
||||
};
|
||||
|
@ -193,7 +193,7 @@ impl ImportedTypes for syn::Path {
|
||||
seg.arguments.imported_types(f);
|
||||
}
|
||||
f(
|
||||
&self.segments.last().unwrap().value().ident,
|
||||
&self.segments.last().unwrap().ident,
|
||||
ImportedTypeKind::Reference,
|
||||
);
|
||||
}
|
||||
@ -272,12 +272,24 @@ impl ImportedTypes for ast::Function {
|
||||
}
|
||||
}
|
||||
|
||||
impl ImportedTypes for syn::ArgCaptured {
|
||||
impl ImportedTypes for syn::FnArg {
|
||||
fn imported_types<F>(&self, f: &mut F)
|
||||
where
|
||||
F: FnMut(&Ident, ImportedTypeKind),
|
||||
{
|
||||
self.ty.imported_types(f);
|
||||
match self {
|
||||
syn::FnArg::Receiver(_) => {}
|
||||
syn::FnArg::Typed(p) => p.imported_types(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ImportedTypes for syn::PatType {
|
||||
fn imported_types<F>(&self, f: &mut F)
|
||||
where
|
||||
F: FnMut(&Ident, ImportedTypeKind),
|
||||
{
|
||||
self.ty.imported_types(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,11 +197,10 @@ fn shared_function<'a>(func: &'a ast::Function, _intern: &'a Interner) -> Functi
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(idx, arg)| {
|
||||
if let syn::Pat::Ident(ref x) = arg.pat {
|
||||
x.ident.to_string()
|
||||
} else {
|
||||
format!("arg{}", idx)
|
||||
if let syn::Pat::Ident(x) = &*arg.pat {
|
||||
return x.ident.to_string()
|
||||
}
|
||||
format!("arg{}", idx)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
Function {
|
||||
|
Reference in New Issue
Block a user