diff options
| author | kennytm <kennytm@gmail.com> | 2018-03-22 17:51:40 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-03-22 22:43:53 +0800 |
| commit | eb99deb9c61704ff4a511ea375ae6ba7dbd980c4 (patch) | |
| tree | 294a6df00d657e1bf8e81070b8d14bf4545ee588 | |
| parent | a10db970692fbf1907aa198c542d30ffc9449d7d (diff) | |
| parent | 99b49b532c8fa2b45179ff346089d9527d05a7a6 (diff) | |
| download | rust-eb99deb9c61704ff4a511ea375ae6ba7dbd980c4.tar.gz rust-eb99deb9c61704ff4a511ea375ae6ba7dbd980c4.zip | |
Rollup merge of #49242 - Mrowqa:typaram-attrs, r=petrochenkov
Pass attributes to hir::TyParam Required by https://github.com/servo/servo/pull/20264 Discussed here: https://gitter.im/servo/servo?at=5aafdcd1012ff2bf681da97a CC @nikomatsakis
| -rw-r--r-- | src/librustc/hir/lowering.rs | 4 | ||||
| -rw-r--r-- | src/librustc/hir/map/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/hir/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ich/impls_hir.rs | 3 |
4 files changed, 7 insertions, 2 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 1439410f7e9..f6bdfde15fc 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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() } @@ -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 { @@ -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), } } diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 61fae4609d5..e8bcbfbb77a 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -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(_)) => { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 5ae84f5685e..d6810b2468b 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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)] diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index e764cedd658..774b1442b71 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -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 { |
