diff options
| author | varkor <github@varkor.com> | 2018-06-13 13:29:40 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-06-20 12:23:23 +0100 |
| commit | 8bc3a35576dd4e2f02b9d34fe5ed241288b5bfbe (patch) | |
| tree | 0958e977d89471eb1c3d1d3a2f16fee8d363a5a4 /src/libsyntax/attr.rs | |
| parent | 390aa5d42152909d927a84a04621f334397d3164 (diff) | |
| download | rust-8bc3a35576dd4e2f02b9d34fe5ed241288b5bfbe.tar.gz rust-8bc3a35576dd4e2f02b9d34fe5ed241288b5bfbe.zip | |
Fix HasAttrs support for GenericParam
Diffstat (limited to 'src/libsyntax/attr.rs')
| -rw-r--r-- | src/libsyntax/attr.rs | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2389ed799cf..ded493fe395 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -1446,17 +1446,12 @@ impl HasAttrs for Stmt { impl HasAttrs for GenericParam { fn attrs(&self) -> &[ast::Attribute] { - match self { - GenericParam::Lifetime(lifetime) => lifetime.attrs(), - GenericParam::Type(ty) => ty.attrs(), - } + &self.attrs } - fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(self, f: F) -> Self { - match self { - GenericParam::Lifetime(lifetime) => GenericParam::Lifetime(lifetime.map_attrs(f)), - GenericParam::Type(ty) => GenericParam::Type(ty.map_attrs(f)), - } + fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(mut self, f: F) -> Self { + self.attrs = self.attrs.map_attrs(f); + self } } @@ -1479,5 +1474,5 @@ macro_rules! derive_has_attrs { derive_has_attrs! { Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::ImplItem, ast::TraitItem, ast::Arm, - ast::Field, ast::FieldPat, ast::Variant_, ast::LifetimeDef, ast::TyParam + ast::Field, ast::FieldPat, ast::Variant_ } |
