Skip to content

Commit 8bc3a35

Browse files
committed
Fix HasAttrs support for GenericParam
1 parent 390aa5d commit 8bc3a35

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/libsyntax/attr.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,17 +1446,12 @@ impl HasAttrs for Stmt {
14461446

14471447
impl HasAttrs for GenericParam {
14481448
fn attrs(&self) -> &[ast::Attribute] {
1449-
match self {
1450-
GenericParam::Lifetime(lifetime) => lifetime.attrs(),
1451-
GenericParam::Type(ty) => ty.attrs(),
1452-
}
1449+
&self.attrs
14531450
}
14541451

1455-
fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(self, f: F) -> Self {
1456-
match self {
1457-
GenericParam::Lifetime(lifetime) => GenericParam::Lifetime(lifetime.map_attrs(f)),
1458-
GenericParam::Type(ty) => GenericParam::Type(ty.map_attrs(f)),
1459-
}
1452+
fn map_attrs<F: FnOnce(Vec<Attribute>) -> Vec<Attribute>>(mut self, f: F) -> Self {
1453+
self.attrs = self.attrs.map_attrs(f);
1454+
self
14601455
}
14611456
}
14621457

@@ -1479,5 +1474,5 @@ macro_rules! derive_has_attrs {
14791474

14801475
derive_has_attrs! {
14811476
Item, Expr, Local, ast::ForeignItem, ast::StructField, ast::ImplItem, ast::TraitItem, ast::Arm,
1482-
ast::Field, ast::FieldPat, ast::Variant_, ast::LifetimeDef, ast::TyParam
1477+
ast::Field, ast::FieldPat, ast::Variant_
14831478
}

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4752,7 +4752,7 @@ impl<'a> Parser<'a> {
47524752
self.span_err(question_span,
47534753
"`?` may only modify trait bounds, not lifetime bounds");
47544754
}
4755-
bounds.push(Outlives(RegionTyParamBound(self.expect_lifetime())));
4755+
bounds.push(Outlives(self.expect_lifetime()));
47564756
if has_parens {
47574757
self.expect(&token::CloseDelim(token::Paren))?;
47584758
self.span_err(self.prev_span,

0 commit comments

Comments
 (0)