Skip to content

Commit

Permalink
Rollup merge of rust-lang#49242 - Mrowqa:typaram-attrs, r=petrochenkov
Browse files Browse the repository at this point in the history
Pass attributes to hir::TyParam

Required by servo/servo#20264
Discussed here: https://gitter.im/servo/servo?at=5aafdcd1012ff2bf681da97a

CC @nikomatsakis
  • Loading branch information
kennytm committed Mar 22, 2018
2 parents a10db97 + 99b49b5 commit eb99deb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_attrs(&mut self, attrs: &Vec<Attribute>) -> hir::HirVec<Attribute> {
fn lower_attrs(&mut self, attrs: &[Attribute]) -> hir::HirVec<Attribute> {
attrs.iter().map(|a| self.lower_attr(a)).collect::<Vec<_>>().into()
}

Expand Down Expand Up @@ -1019,6 +1019,7 @@ impl<'a> LoweringContext<'a> {
span,
pure_wrt_drop: false,
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
attrs: P::new(),
});

hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
Expand Down Expand Up @@ -1585,6 +1586,7 @@ impl<'a> LoweringContext<'a> {
.filter(|attr| attr.check_name("rustc_synthetic"))
.map(|_| hir::SyntheticTyParamKind::ImplTrait)
.nth(0),
attrs: self.lower_attrs(&tp.attrs),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ impl<'hir> Map<'hir> {
Some(NodeField(ref f)) => Some(&f.attrs[..]),
Some(NodeExpr(ref e)) => Some(&*e.attrs),
Some(NodeStmt(ref s)) => Some(s.node.attrs()),
Some(NodeTyParam(tp)) => Some(&tp.attrs[..]),
// unit/tuple structs take the attributes straight from
// the struct definition.
Some(NodeStructCtor(_)) => {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ pub struct TyParam {
pub span: Span,
pub pure_wrt_drop: bool,
pub synthetic: Option<SyntheticTyParamKind>,
pub attrs: HirVec<Attribute>,
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ impl_stable_hash_for!(struct hir::TyParam {
default,
span,
pure_wrt_drop,
synthetic
synthetic,
attrs
});

impl_stable_hash_for!(enum hir::GenericParam {
Expand Down

0 comments on commit eb99deb

Please sign in to comment.