mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-14 12:02:23 +03:00
Merge pull request #1720 from alexcrichton/update-syn
Upgrade to syn/quote 1.0
This commit is contained in:
commit
8775f9b1b3
@ -19,7 +19,7 @@ extra-traits = ["syn/extra-traits"]
|
||||
bumpalo = "2.1"
|
||||
lazy_static = "1.0.0"
|
||||
log = "0.4"
|
||||
proc-macro2 = "0.4.8"
|
||||
quote = '0.6'
|
||||
syn = { version = '0.15', features = ['full'] }
|
||||
proc-macro2 = "1.0"
|
||||
quote = '1.0'
|
||||
syn = { version = '1.0', features = ['full'] }
|
||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }
|
||||
|
@ -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 {
|
||||
|
@ -17,8 +17,8 @@ extra-traits = ["syn/extra-traits"]
|
||||
strict-macro = []
|
||||
|
||||
[dependencies]
|
||||
syn = { version = '0.15.0', features = ['visit'] }
|
||||
quote = '0.6'
|
||||
proc-macro2 = "0.4.9"
|
||||
syn = { version = '1.0', features = ['visit'] }
|
||||
quote = '1.0'
|
||||
proc-macro2 = "1.0"
|
||||
wasm-bindgen-backend = { path = "../backend", version = "=0.2.48" }
|
||||
wasm-bindgen-shared = { path = "../shared", version = "=0.2.48" }
|
||||
|
@ -158,7 +158,7 @@ impl BindgenAttrs {
|
||||
None => return Ok(ret),
|
||||
};
|
||||
let attr = attrs.remove(pos);
|
||||
let mut tts = attr.tts.clone().into_iter();
|
||||
let mut tts = attr.tokens.clone().into_iter();
|
||||
let group = match tts.next() {
|
||||
Some(TokenTree::Group(d)) => d,
|
||||
Some(_) => bail_span!(attr, "malformed #[wasm_bindgen] attribute"),
|
||||
@ -373,9 +373,9 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
|
||||
(opts, module): (BindgenAttrs, &'a ast::ImportModule),
|
||||
) -> Result<Self::Target, Diagnostic> {
|
||||
let wasm = function_from_decl(
|
||||
&self.ident,
|
||||
&self.sig.ident,
|
||||
&opts,
|
||||
self.decl.clone(),
|
||||
self.sig.clone(),
|
||||
self.attrs.clone(),
|
||||
self.vis.clone(),
|
||||
false,
|
||||
@ -403,10 +403,10 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
|
||||
let class = wasm.arguments.get(0).ok_or_else(|| {
|
||||
err_span!(self, "imported methods must have at least one argument")
|
||||
})?;
|
||||
let class = match class.ty {
|
||||
let class = match &*class.ty {
|
||||
syn::Type::Reference(syn::TypeReference {
|
||||
mutability: None,
|
||||
ref elem,
|
||||
elem,
|
||||
..
|
||||
}) => &**elem,
|
||||
_ => bail_span!(
|
||||
@ -482,7 +482,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
|
||||
ast::ImportFunctionKind::Normal => (0, "n"),
|
||||
ast::ImportFunctionKind::Method { ref class, .. } => (1, &class[..]),
|
||||
};
|
||||
let data = (ns, &self.ident, module);
|
||||
let data = (ns, &self.sig.ident, module);
|
||||
format!(
|
||||
"__wbg_{}_{}",
|
||||
wasm.name
|
||||
@ -507,7 +507,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
|
||||
catch,
|
||||
variadic,
|
||||
structural: opts.structural().is_some() || opts.r#final().is_none(),
|
||||
rust_name: self.ident.clone(),
|
||||
rust_name: self.sig.ident.clone(),
|
||||
shim: Ident::new(&shim, Span::call_site()),
|
||||
doc_comment: None,
|
||||
});
|
||||
@ -599,21 +599,21 @@ impl ConvertToAst<BindgenAttrs> for syn::ItemFn {
|
||||
syn::Visibility::Public(_) => {}
|
||||
_ => bail_span!(self, "can only #[wasm_bindgen] public functions"),
|
||||
}
|
||||
if self.constness.is_some() {
|
||||
if self.sig.constness.is_some() {
|
||||
bail_span!(
|
||||
self.constness,
|
||||
self.sig.constness,
|
||||
"can only #[wasm_bindgen] non-const functions"
|
||||
);
|
||||
}
|
||||
if self.unsafety.is_some() {
|
||||
bail_span!(self.unsafety, "can only #[wasm_bindgen] safe functions");
|
||||
if self.sig.unsafety.is_some() {
|
||||
bail_span!(self.sig.unsafety, "can only #[wasm_bindgen] safe functions");
|
||||
}
|
||||
assert_not_variadic(&attrs)?;
|
||||
|
||||
let ret = function_from_decl(
|
||||
&self.ident,
|
||||
&self.sig.ident,
|
||||
&attrs,
|
||||
self.decl,
|
||||
self.sig.clone(),
|
||||
self.attrs,
|
||||
self.vis,
|
||||
false,
|
||||
@ -628,25 +628,25 @@ impl ConvertToAst<BindgenAttrs> for syn::ItemFn {
|
||||
fn function_from_decl(
|
||||
decl_name: &syn::Ident,
|
||||
opts: &BindgenAttrs,
|
||||
decl: Box<syn::FnDecl>,
|
||||
sig: syn::Signature,
|
||||
attrs: Vec<syn::Attribute>,
|
||||
vis: syn::Visibility,
|
||||
allow_self: bool,
|
||||
self_ty: Option<&Ident>,
|
||||
) -> Result<(ast::Function, Option<ast::MethodSelf>), Diagnostic> {
|
||||
if decl.variadic.is_some() {
|
||||
bail_span!(decl.variadic, "can't #[wasm_bindgen] variadic functions");
|
||||
if sig.variadic.is_some() {
|
||||
bail_span!(sig.variadic, "can't #[wasm_bindgen] variadic functions");
|
||||
}
|
||||
if decl.generics.params.len() > 0 {
|
||||
if sig.generics.params.len() > 0 {
|
||||
bail_span!(
|
||||
decl.generics,
|
||||
sig.generics,
|
||||
"can't #[wasm_bindgen] functions with lifetime or type parameters",
|
||||
);
|
||||
}
|
||||
|
||||
assert_no_lifetimes(&decl)?;
|
||||
assert_no_lifetimes(&sig)?;
|
||||
|
||||
let syn::FnDecl { inputs, output, .. } = { *decl };
|
||||
let syn::Signature { inputs, output, .. } = sig;
|
||||
|
||||
let replace_self = |t: syn::Type| {
|
||||
let self_ty = match self_ty {
|
||||
@ -672,25 +672,24 @@ fn function_from_decl(
|
||||
let arguments = inputs
|
||||
.into_iter()
|
||||
.filter_map(|arg| match arg {
|
||||
syn::FnArg::Captured(mut c) => {
|
||||
c.ty = replace_self(c.ty);
|
||||
syn::FnArg::Typed(mut c) => {
|
||||
c.ty = Box::new(replace_self(*c.ty));
|
||||
Some(c)
|
||||
}
|
||||
syn::FnArg::SelfValue(_) => {
|
||||
syn::FnArg::Receiver(r) => {
|
||||
if !allow_self {
|
||||
panic!("arguments cannot be `self`")
|
||||
}
|
||||
assert!(method_self.is_none());
|
||||
method_self = Some(ast::MethodSelf::ByValue);
|
||||
None
|
||||
}
|
||||
syn::FnArg::SelfRef(ref a) if allow_self => {
|
||||
assert!(method_self.is_none());
|
||||
if a.mutability.is_some() {
|
||||
if r.reference.is_none() {
|
||||
method_self = Some(ast::MethodSelf::ByValue);
|
||||
} else if r.mutability.is_some() {
|
||||
method_self = Some(ast::MethodSelf::RefMutable);
|
||||
} else {
|
||||
method_self = Some(ast::MethodSelf::RefShared);
|
||||
}
|
||||
None
|
||||
}
|
||||
_ => panic!("arguments cannot be `self` or ignored"),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@ -739,8 +738,8 @@ impl<'a> MacroParse<(Option<BindgenAttrs>, &'a mut TokenStream)> for syn::Item {
|
||||
.attrs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, m)| m.interpret_meta().map(|m| (i, m)))
|
||||
.find(|&(_, ref m)| m.name() == "no_mangle");
|
||||
.filter_map(|(i, m)| m.parse_meta().ok().map(|m| (i, m)))
|
||||
.find(|(_, m)| m.path().is_ident("no_mangle"));
|
||||
match no_mangle {
|
||||
Some((i, _)) => {
|
||||
f.attrs.remove(i);
|
||||
@ -751,18 +750,18 @@ impl<'a> MacroParse<(Option<BindgenAttrs>, &'a mut TokenStream)> for syn::Item {
|
||||
f.to_tokens(tokens);
|
||||
let opts = opts.unwrap_or_default();
|
||||
if opts.start().is_some() {
|
||||
if f.decl.generics.params.len() > 0 {
|
||||
bail_span!(&f.decl.generics, "the start function cannot have generics",);
|
||||
if f.sig.generics.params.len() > 0 {
|
||||
bail_span!(&f.sig.generics, "the start function cannot have generics",);
|
||||
}
|
||||
if f.decl.inputs.len() > 0 {
|
||||
bail_span!(&f.decl.inputs, "the start function cannot have arguments",);
|
||||
if f.sig.inputs.len() > 0 {
|
||||
bail_span!(&f.sig.inputs, "the start function cannot have arguments",);
|
||||
}
|
||||
}
|
||||
let method_kind = ast::MethodKind::Operation(ast::Operation {
|
||||
is_static: true,
|
||||
kind: operation_kind(&opts),
|
||||
});
|
||||
let rust_name = f.ident.clone();
|
||||
let rust_name = f.sig.ident.clone();
|
||||
let start = opts.start().is_some();
|
||||
program.exports.push(ast::Export {
|
||||
comments,
|
||||
@ -893,10 +892,6 @@ fn prepare_for_impl_recursion(
|
||||
&*item,
|
||||
"type definitions in impls aren't supported with #[wasm_bindgen]"
|
||||
),
|
||||
syn::ImplItem::Existential(_) => bail_span!(
|
||||
&*item,
|
||||
"existentials in impls aren't supported with #[wasm_bindgen]"
|
||||
),
|
||||
syn::ImplItem::Macro(_) => {
|
||||
// In theory we want to allow this, but we have no way of expanding
|
||||
// the macro and then placing our magical attributes on the expanded
|
||||
@ -905,6 +900,7 @@ fn prepare_for_impl_recursion(
|
||||
bail_span!(&*item, "macros in impls aren't supported");
|
||||
}
|
||||
syn::ImplItem::Verbatim(_) => panic!("unparsed impl item?"),
|
||||
other => bail_span!(other, "failed to parse this item as a known item"),
|
||||
};
|
||||
|
||||
let js_class = impl_opts
|
||||
@ -919,7 +915,7 @@ fn prepare_for_impl_recursion(
|
||||
style: syn::AttrStyle::Outer,
|
||||
bracket_token: Default::default(),
|
||||
path: syn::parse_quote! { wasm_bindgen::prelude::__wasm_bindgen_class_marker },
|
||||
tts: quote::quote! { (#class = #js_class) }.into(),
|
||||
tokens: quote::quote! { (#class = #js_class) }.into(),
|
||||
},
|
||||
);
|
||||
|
||||
@ -954,7 +950,7 @@ impl<'a, 'b> MacroParse<(&'a Ident, &'a str)> for &'b mut syn::ImplItemMethod {
|
||||
let (function, method_self) = function_from_decl(
|
||||
&self.sig.ident,
|
||||
&opts,
|
||||
Box::new(self.sig.decl.clone()),
|
||||
self.sig.clone(),
|
||||
self.attrs.clone(),
|
||||
self.vis.clone(),
|
||||
true,
|
||||
@ -1015,25 +1011,27 @@ impl MacroParse<()> for syn::ItemEnum {
|
||||
);
|
||||
}
|
||||
|
||||
let value = match v.discriminant {
|
||||
let value = match &v.discriminant {
|
||||
Some((
|
||||
_,
|
||||
syn::Expr::Lit(syn::ExprLit {
|
||||
attrs: _,
|
||||
lit: syn::Lit::Int(ref int_lit),
|
||||
lit: syn::Lit::Int(int_lit),
|
||||
}),
|
||||
)) => {
|
||||
if int_lit.value() > <u32>::max_value() as u64 {
|
||||
bail_span!(
|
||||
int_lit,
|
||||
"enums with #[wasm_bindgen] can only support \
|
||||
numbers that can be represented as u32"
|
||||
);
|
||||
match int_lit.base10_digits().parse::<u32>() {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
bail_span!(
|
||||
int_lit,
|
||||
"enums with #[wasm_bindgen] can only support \
|
||||
numbers that can be represented as u32"
|
||||
);
|
||||
}
|
||||
}
|
||||
int_lit.value() as u32
|
||||
}
|
||||
None => i as u32,
|
||||
Some((_, ref expr)) => bail_span!(
|
||||
Some((_, expr)) => bail_span!(
|
||||
expr,
|
||||
"enums with #[wasm_bidngen] may only have \
|
||||
number literal values",
|
||||
@ -1196,8 +1194,7 @@ fn extract_first_ty_param(ty: Option<&syn::Type>) -> Result<Option<syn::Type>, D
|
||||
let seg = path
|
||||
.segments
|
||||
.last()
|
||||
.ok_or_else(|| err_span!(t, "must have at least one segment"))?
|
||||
.into_value();
|
||||
.ok_or_else(|| err_span!(t, "must have at least one segment"))?;
|
||||
let generics = match seg.arguments {
|
||||
syn::PathArguments::AngleBracketed(ref t) => t,
|
||||
_ => bail_span!(t, "must be Result<...>"),
|
||||
@ -1205,14 +1202,13 @@ fn extract_first_ty_param(ty: Option<&syn::Type>) -> Result<Option<syn::Type>, D
|
||||
let generic = generics
|
||||
.args
|
||||
.first()
|
||||
.ok_or_else(|| err_span!(t, "must have at least one generic parameter"))?
|
||||
.into_value();
|
||||
.ok_or_else(|| err_span!(t, "must have at least one generic parameter"))?;
|
||||
let ty = match generic {
|
||||
syn::GenericArgument::Type(t) => t,
|
||||
other => bail_span!(other, "must be a type parameter"),
|
||||
};
|
||||
match *ty {
|
||||
syn::Type::Tuple(ref t) if t.elems.len() == 0 => return Ok(None),
|
||||
match ty {
|
||||
syn::Type::Tuple(t) if t.elems.len() == 0 => return Ok(None),
|
||||
_ => {}
|
||||
}
|
||||
Ok(Some(ty.clone()))
|
||||
@ -1228,7 +1224,7 @@ fn extract_doc_comments(attrs: &[syn::Attribute]) -> Vec<String> {
|
||||
if a.path.segments.iter().any(|s| s.ident.to_string() == "doc") {
|
||||
Some(
|
||||
// We want to filter out any Puncts so just grab the Literals
|
||||
a.tts.clone().into_iter().filter_map(|t| match t {
|
||||
a.tokens.clone().into_iter().filter_map(|t| match t {
|
||||
TokenTree::Literal(lit) => {
|
||||
// this will always return the quoted string, we deal with
|
||||
// that in the cli when we read in the comments
|
||||
@ -1249,7 +1245,7 @@ fn extract_doc_comments(attrs: &[syn::Attribute]) -> Vec<String> {
|
||||
}
|
||||
|
||||
/// Check there are no lifetimes on the function.
|
||||
fn assert_no_lifetimes(decl: &syn::FnDecl) -> Result<(), Diagnostic> {
|
||||
fn assert_no_lifetimes(sig: &syn::Signature) -> Result<(), Diagnostic> {
|
||||
struct Walk {
|
||||
diagnostics: Vec<Diagnostic>,
|
||||
}
|
||||
@ -1266,7 +1262,7 @@ fn assert_no_lifetimes(decl: &syn::FnDecl) -> Result<(), Diagnostic> {
|
||||
let mut walk = Walk {
|
||||
diagnostics: Vec::new(),
|
||||
};
|
||||
syn::visit::Visit::visit_fn_decl(&mut walk, decl);
|
||||
syn::visit::Visit::visit_signature(&mut walk, sig);
|
||||
Diagnostic::from_vec(walk.diagnostics)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ strict-macro = ["wasm-bindgen-macro-support/strict-macro"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.48" }
|
||||
quote = "0.6"
|
||||
quote = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
trybuild = "1.0"
|
||||
|
@ -8,8 +8,8 @@ serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
||||
proc-macro2 = "0.4.8"
|
||||
quote = "0.6"
|
||||
syn = { version = "0.15", default-features = false }
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "1.0", default-features = false }
|
||||
wasm-bindgen = { path = "../..", default-features = false }
|
||||
wasm-bindgen-backend = { path = "../backend", default-features = false }
|
||||
|
@ -16,8 +16,8 @@ edition = "2018"
|
||||
failure = "0.1.2"
|
||||
heck = "0.3"
|
||||
log = "0.4.1"
|
||||
proc-macro2 = "0.4.8"
|
||||
quote = '0.6'
|
||||
syn = { version = '0.15', features = ['full'] }
|
||||
proc-macro2 = "1.0"
|
||||
quote = '1.0'
|
||||
syn = { version = '1.0', features = ['full'] }
|
||||
wasm-bindgen-backend = { version = "=0.2.48", path = "../backend" }
|
||||
weedle = "0.10"
|
||||
|
@ -577,7 +577,7 @@ impl<'a> IdlType<'a> {
|
||||
.path
|
||||
.segments
|
||||
.last()
|
||||
.map(|p| p.value().ident == "JsValue")
|
||||
.map(|p| p.ident == "JsValue")
|
||||
.unwrap_or(false)
|
||||
{
|
||||
return Some(inner.clone());
|
||||
|
@ -121,7 +121,7 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>) -> Result<Program>
|
||||
for import in program.imports.iter_mut() {
|
||||
if let ast::ImportKind::Type(t) = &mut import.kind {
|
||||
t.extends.retain(|n| {
|
||||
let ident = &n.segments.last().unwrap().value().ident;
|
||||
let ident = &n.segments.last().unwrap().ident;
|
||||
first_pass_record.builtin_idents.contains(ident) || filter(&ident.to_string())
|
||||
});
|
||||
}
|
||||
|
@ -127,16 +127,18 @@ pub fn webidl_const_v_to_backend_const_v(v: &ConstValue) -> ast::ConstValue {
|
||||
}
|
||||
|
||||
/// From `ident` and `Ty`, create `ident: Ty` for use in e.g. `fn(ident: Ty)`.
|
||||
fn simple_fn_arg(ident: Ident, ty: syn::Type) -> syn::ArgCaptured {
|
||||
syn::ArgCaptured {
|
||||
pat: syn::Pat::Ident(syn::PatIdent {
|
||||
fn simple_fn_arg(ident: Ident, ty: syn::Type) -> syn::PatType {
|
||||
syn::PatType {
|
||||
pat: Box::new(syn::Pat::Ident(syn::PatIdent {
|
||||
attrs: Vec::new(),
|
||||
by_ref: None,
|
||||
mutability: None,
|
||||
ident,
|
||||
mutability: None,
|
||||
subpat: None,
|
||||
}),
|
||||
})),
|
||||
colon_token: Default::default(),
|
||||
ty,
|
||||
ty: Box::new(ty),
|
||||
attrs: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user