]> git.lizzy.rs Git - rust.git/commitdiff
Fix HasAttrs support for GenericParam
authorvarkor <github@varkor.com>
Wed, 13 Jun 2018 12:29:40 +0000 (13:29 +0100)
committervarkor <github@varkor.com>
Wed, 20 Jun 2018 11:23:23 +0000 (12:23 +0100)
src/libsyntax/attr.rs
src/libsyntax/parse/parser.rs

index 2389ed799cfcc268301e70275aac9b3c190f029f..ded493fe3958c4f57a8e32db2e11a74646e08f4a 100644 (file)
@@ -1446,17 +1446,12 @@ fn map_attrs<F: FnOnce(Vec<ast::Attribute>) -> Vec<ast::Attribute>>(self, f: F)
 
 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 @@ fn map_attrs<F>(mut self, f: F) -> Self
 
 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_
 }
index b2cfb459c359a2e32313fd73d3182185f035ed34..f69361c28ad00d5588fe9472f2c5dfc5428c55b3 100644 (file)
@@ -4752,7 +4752,7 @@ fn parse_ty_param_bounds_common(&mut self, allow_plus: bool) -> PResult<'a, Para
                         self.span_err(question_span,
                                       "`?` may only modify trait bounds, not lifetime bounds");
                     }
-                    bounds.push(Outlives(RegionTyParamBound(self.expect_lifetime())));
+                    bounds.push(Outlives(self.expect_lifetime()));
                     if has_parens {
                         self.expect(&token::CloseDelim(token::Paren))?;
                         self.span_err(self.prev_span,