Simplify using ..

This commit is contained in:
Stephen Chung
2022-02-08 09:02:15 +08:00
parent 187a20fd8b
commit f8cee0fe4e
54 changed files with 1184 additions and 1190 deletions

View File

@@ -252,7 +252,7 @@ impl ExportedParams for ExportedFnParams {
}
}
(attr, _) => {
(attr, ..) => {
return Err(syn::Error::new(
key.span(),
format!("unknown attribute '{}'", attr),
@@ -379,7 +379,7 @@ impl Parse for ExportedFn {
// Check return type.
match fn_all.sig.output {
syn::ReturnType::Type(_, ref ret_type) => {
syn::ReturnType::Type(.., ref ret_type) => {
match flatten_type_groups(ret_type.as_ref()) {
syn::Type::Ptr(_) => {
return Err(syn::Error::new(
@@ -425,10 +425,10 @@ impl ExportedFn {
pub fn update_scope(&mut self, parent_scope: &ExportScope) {
let keep = match (self.params.skip, parent_scope) {
(true, _) => false,
(_, ExportScope::PubOnly) => self.is_public(),
(_, ExportScope::Prefix(s)) => self.name().to_string().starts_with(s),
(_, ExportScope::All) => true,
(true, ..) => false,
(.., ExportScope::PubOnly) => self.is_public(),
(.., ExportScope::Prefix(s)) => self.name().to_string().starts_with(s),
(.., ExportScope::All) => true,
};
self.params.skip = !keep;
}
@@ -502,7 +502,7 @@ impl ExportedFn {
pub fn return_type(&self) -> Option<&syn::Type> {
match self.signature.output {
syn::ReturnType::Type(_, ref ret_type) => Some(flatten_type_groups(ret_type)),
syn::ReturnType::Type(.., ref ret_type) => Some(flatten_type_groups(ret_type)),
_ => None,
}
}

View File

@@ -69,7 +69,7 @@ impl ExportedParams for ExportedModParams {
("export_all", Some(s)) => {
return Err(syn::Error::new(s.span(), "extraneous value"))
}
(attr, _) => {
(attr, ..) => {
return Err(syn::Error::new(
key.span(),
format!("unknown attribute '{}'", attr),
@@ -109,7 +109,7 @@ impl Parse for Module {
let mut consts = Vec::new();
let mut sub_modules = Vec::new();
if let Some((_, ref mut content)) = mod_all.content {
if let Some((.., ref mut content)) = mod_all.content {
// Gather and parse functions.
fns = content
.iter_mut()
@@ -211,10 +211,10 @@ impl Module {
pub fn update_scope(&mut self, parent_scope: &ExportScope) {
let keep = match (self.params.skip, parent_scope) {
(true, _) => false,
(_, ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(_)),
(_, ExportScope::Prefix(s)) => self.mod_all.ident.to_string().starts_with(s),
(_, ExportScope::All) => true,
(true, ..) => false,
(.., ExportScope::PubOnly) => matches!(self.mod_all.vis, syn::Visibility::Public(_)),
(.., ExportScope::Prefix(s)) => self.mod_all.ident.to_string().starts_with(s),
(.., ExportScope::All) => true,
};
self.params.skip = !keep;
}
@@ -245,7 +245,7 @@ impl Module {
} = self;
let mod_vis = mod_all.vis;
let mod_name = mod_all.ident.clone();
let (_, orig_content) = mod_all.content.take().unwrap();
let (.., orig_content) = mod_all.content.take().unwrap();
let mod_attrs = mem::take(&mut mod_all.attrs);
if !params.skip {
@@ -312,7 +312,7 @@ impl Module {
pub fn content(&self) -> Option<&[syn::Item]> {
match self.mod_all {
syn::ItemMod {
content: Some((_, ref vec)),
content: Some((.., ref vec)),
..
} => Some(vec),
_ => None,

View File

@@ -240,7 +240,7 @@ pub fn generate_body(
})
.unwrap();
let (_, generate_call_content) = generate_fn_call.content.take().unwrap();
let (.., generate_call_content) = generate_fn_call.content.take().unwrap();
quote! {
#(#generate_call_content)*
@@ -275,7 +275,7 @@ pub fn check_rename_collisions(fns: &[ExportedFn]) -> Result<(), syn::Error> {
.map(|n| (n.clone(), n.clone()))
.collect();
if let Some((s, n, _)) = item_fn.params().special.get_fn_name() {
if let Some((s, n, ..)) = item_fn.params().special.get_fn_name() {
names.push((s, n));
}