Skip to content

Commit eb99deb

Browse files
committed
Rollup merge of #49242 - Mrowqa:typaram-attrs, r=petrochenkov
Pass attributes to hir::TyParam Required by servo/servo#20264 Discussed here: https://gitter.im/servo/servo?at=5aafdcd1012ff2bf681da97a CC @nikomatsakis
2 parents a10db97 + 99b49b5 commit eb99deb

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/librustc/hir/lowering.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl<'a> LoweringContext<'a> {
809809
}
810810
}
811811

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

@@ -1019,6 +1019,7 @@ impl<'a> LoweringContext<'a> {
10191019
span,
10201020
pure_wrt_drop: false,
10211021
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
1022+
attrs: P::new(),
10221023
});
10231024

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

src/librustc/hir/map/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ impl<'hir> Map<'hir> {
962962
Some(NodeField(ref f)) => Some(&f.attrs[..]),
963963
Some(NodeExpr(ref e)) => Some(&*e.attrs),
964964
Some(NodeStmt(ref s)) => Some(s.node.attrs()),
965+
Some(NodeTyParam(tp)) => Some(&tp.attrs[..]),
965966
// unit/tuple structs take the attributes straight from
966967
// the struct definition.
967968
Some(NodeStructCtor(_)) => {

src/librustc/hir/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ pub struct TyParam {
414414
pub span: Span,
415415
pub pure_wrt_drop: bool,
416416
pub synthetic: Option<SyntheticTyParamKind>,
417+
pub attrs: HirVec<Attribute>,
417418
}
418419

419420
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]

src/librustc/ich/impls_hir.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ impl_stable_hash_for!(struct hir::TyParam {
203203
default,
204204
span,
205205
pure_wrt_drop,
206-
synthetic
206+
synthetic,
207+
attrs
207208
});
208209

209210
impl_stable_hash_for!(enum hir::GenericParam {

0 commit comments

Comments
 (0)