diff --git a/src/librustc_expand/base.rs b/src/librustc_expand/base.rs index 9debae19fa5..af02070828a 100644 --- a/src/librustc_expand/base.rs +++ b/src/librustc_expand/base.rs @@ -62,7 +62,7 @@ fn attrs(&self) -> &[Attribute] { } } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { match self { Annotatable::Item(item) => item.visit_attrs(f), Annotatable::TraitItem(trait_item) => trait_item.visit_attrs(f), diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs index 419297678d2..a78fbe276fa 100644 --- a/src/libsyntax/attr/mod.rs +++ b/src/libsyntax/attr/mod.rs @@ -657,15 +657,15 @@ fn from_tokens(tokens: &mut iter::Peekable) -> Option } pub trait HasAttrs: Sized { - fn attrs(&self) -> &[ast::Attribute]; - fn visit_attrs)>(&mut self, f: F); + fn attrs(&self) -> &[Attribute]; + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)); } impl HasAttrs for Spanned { - fn attrs(&self) -> &[ast::Attribute] { + fn attrs(&self) -> &[Attribute] { self.node.attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.node.visit_attrs(f); } } @@ -674,7 +674,7 @@ impl HasAttrs for Vec { fn attrs(&self) -> &[Attribute] { self } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { f(self) } } @@ -683,7 +683,7 @@ impl HasAttrs for AttrVec { fn attrs(&self) -> &[Attribute] { self } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { visit_clobber(self, |this| { let mut vec = this.into(); f(&mut vec); @@ -696,7 +696,7 @@ impl HasAttrs for P { fn attrs(&self) -> &[Attribute] { (**self).attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { (**self).visit_attrs(f); } } @@ -714,7 +714,7 @@ fn attrs(&self) -> &[Attribute] { } } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { match self { StmtKind::Local(local) => local.visit_attrs(f), StmtKind::Item(..) => {} @@ -733,21 +733,11 @@ fn attrs(&self) -> &[ast::Attribute] { self.kind.attrs() } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.kind.visit_attrs(f); } } -impl HasAttrs for GenericParam { - fn attrs(&self) -> &[ast::Attribute] { - &self.attrs - } - - fn visit_attrs)>(&mut self, f: F) { - self.attrs.visit_attrs(f); - } -} - macro_rules! derive_has_attrs { ($($ty:path),*) => { $( impl HasAttrs for $ty { @@ -755,7 +745,7 @@ fn attrs(&self) -> &[Attribute] { &self.attrs } - fn visit_attrs)>(&mut self, f: F) { + fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec)) { self.attrs.visit_attrs(f); } } @@ -764,5 +754,5 @@ fn visit_attrs)>(&mut self, f: F) { derive_has_attrs! { Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::AssocItem, ast::Arm, - ast::Field, ast::FieldPat, ast::Variant, ast::Param + ast::Field, ast::FieldPat, ast::Variant, ast::Param, GenericParam }