]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #49242 - Mrowqa:typaram-attrs, r=petrochenkov
authorkennytm <kennytm@gmail.com>
Thu, 22 Mar 2018 09:51:40 +0000 (17:51 +0800)
committerkennytm <kennytm@gmail.com>
Thu, 22 Mar 2018 14:43:53 +0000 (22:43 +0800)
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

src/librustc/hir/lowering.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/ich/impls_hir.rs

index 1439410f7e9aa2ac025f2d23b92363cc77a1f9ff..f6bdfde15fc5ff962cf7f6f12ab90e49a0febe64 100644 (file)
@@ -809,7 +809,7 @@ fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>)
         }
     }
 
-    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 @@ fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> P<hir::Ty> {
                             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 @@ fn lower_ty_param(&mut self, tp: &TyParam, add_bounds: &[TyParamBound]) -> hir::
                                .filter(|attr| attr.check_name("rustc_synthetic"))
                                .map(|_| hir::SyntheticTyParamKind::ImplTrait)
                                .nth(0),
+            attrs: self.lower_attrs(&tp.attrs),
         }
     }
 
index 61fae4609d54fe7813b76857c5baa5fb6e48ed09..e8bcbfbb77a1791cb03d6d65352566accc740c8a 100644 (file)
@@ -962,6 +962,7 @@ pub fn attrs(&self, id: NodeId) -> &'hir [ast::Attribute] {
             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(_)) => {
index 5ae84f5685eafca61a09c0716dd2de7ff76d7a56..d6810b2468bccbed8dc1d332e42847db7b3da388 100644 (file)
@@ -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)]
index e764cedd658b5df4070f031fcd0f5bc33c26c663..774b1442b7101cd0da9aea15ede223d57231ed9b 100644 (file)
@@ -203,7 +203,8 @@ fn hash_stable<W: StableHasherResult>(&self,
     default,
     span,
     pure_wrt_drop,
-    synthetic
+    synthetic,
+    attrs
 });
 
 impl_stable_hash_for!(enum hir::GenericParam {