Fix HasAttrs support for GenericParam

This commit is contained in:
varkor
2018-06-13 13:29:40 +01:00
parent 390aa5d421
commit 8bc3a35576
2 changed files with 6 additions and 11 deletions
+5 -10
View 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_
}
+1 -1
View 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,