Skip to content

Commit 91712bc

Browse files
committed
Lift attrs into hir::GenericParam
1 parent 7de6ed0 commit 91712bc

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,9 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
748748
}
749749
match param.kind {
750750
GenericParamKind::Lifetime { .. } => {}
751-
GenericParamKind::Type { ref default, ref attrs, .. } => {
752-
walk_list!(visitor, visit_ty, default);
753-
walk_list!(visitor, visit_attribute, attrs.iter());
754-
}
751+
GenericParamKind::Type { ref default, .. } => walk_list!(visitor, visit_ty, default),
755752
}
753+
walk_list!(visitor, visit_attribute, &param.attrs);
756754
walk_list!(visitor, visit_param_bound, &param.bounds);
757755
}
758756

src/librustc/hir/lowering.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,10 @@ impl<'a> LoweringContext<'a> {
695695
hir::GenericParam {
696696
id: def_node_id,
697697
name: hir_name,
698+
attrs: hir_vec![],
699+
bounds: hir_vec![],
698700
span,
699701
pure_wrt_drop: false,
700-
bounds: vec![].into(),
701702
kind: hir::GenericParamKind::Lifetime { in_band: true }
702703
}
703704
})
@@ -1239,11 +1240,11 @@ impl<'a> LoweringContext<'a> {
12391240
name: ParamName::Plain(name),
12401241
span,
12411242
pure_wrt_drop: false,
1243+
attrs: hir_vec![],
12421244
bounds: hir_bounds,
12431245
kind: hir::GenericParamKind::Type {
12441246
default: None,
12451247
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
1246-
attrs: P::new(),
12471248
}
12481249
});
12491250

@@ -1413,7 +1414,8 @@ impl<'a> LoweringContext<'a> {
14131414
name,
14141415
span: lifetime.span,
14151416
pure_wrt_drop: false,
1416-
bounds: vec![].into(),
1417+
attrs: hir_vec![],
1418+
bounds: hir_vec![],
14171419
kind: hir::GenericParamKind::Lifetime {
14181420
in_band: false,
14191421
}
@@ -1950,6 +1952,7 @@ impl<'a> LoweringContext<'a> {
19501952
name: param_name,
19511953
span: lt.span,
19521954
pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
1955+
attrs: self.lower_attrs(&param.attrs),
19531956
bounds,
19541957
kind: hir::GenericParamKind::Lifetime { in_band: false }
19551958
};
@@ -1980,6 +1983,7 @@ impl<'a> LoweringContext<'a> {
19801983
name: hir::ParamName::Plain(name),
19811984
span: param.ident.span,
19821985
pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
1986+
attrs: self.lower_attrs(&param.attrs),
19831987
bounds,
19841988
kind: hir::GenericParamKind::Type {
19851989
default: default.as_ref().map(|x| {
@@ -1989,7 +1993,6 @@ impl<'a> LoweringContext<'a> {
19891993
.filter(|attr| attr.check_name("rustc_synthetic"))
19901994
.map(|_| hir::SyntheticTyParamKind::ImplTrait)
19911995
.next(),
1992-
attrs: self.lower_attrs(&param.attrs),
19931996
}
19941997
}
19951998
}

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,7 @@ impl<'hir> Map<'hir> {
974974
Some(NodeField(ref f)) => Some(&f.attrs[..]),
975975
Some(NodeExpr(ref e)) => Some(&*e.attrs),
976976
Some(NodeStmt(ref s)) => Some(s.node.attrs()),
977-
Some(NodeGenericParam(param)) => match param.kind {
978-
GenericParamKind::Lifetime { .. } => None,
979-
GenericParamKind::Type { ref attrs, .. } => Some(&attrs[..]),
980-
}
977+
Some(NodeGenericParam(param)) => Some(&param.attrs[..]),
981978
// unit/tuple structs take the attributes straight from
982979
// the struct definition.
983980
Some(NodeStructCtor(_)) => {

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,14 @@ pub enum GenericParamKind {
471471
Type {
472472
default: Option<P<Ty>>,
473473
synthetic: Option<SyntheticTyParamKind>,
474-
attrs: HirVec<Attribute>,
475474
}
476475
}
477476

478477
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
479478
pub struct GenericParam {
480479
pub id: NodeId,
481480
pub name: ParamName,
481+
pub attrs: HirVec<Attribute>,
482482
pub bounds: ParamBounds,
483483
pub span: Span,
484484
pub pure_wrt_drop: bool,

src/librustc/ich/impls_hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl_stable_hash_for!(struct hir::GenericParam {
203203
name,
204204
span,
205205
pure_wrt_drop,
206+
attrs,
206207
bounds,
207208
kind
208209
});
@@ -216,10 +217,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::GenericParamKind {
216217
hir::GenericParamKind::Lifetime { in_band } => {
217218
in_band.hash_stable(hcx, hasher);
218219
}
219-
hir::GenericParamKind::Type { ref default, synthetic, attrs } => {
220+
hir::GenericParamKind::Type { ref default, synthetic } => {
220221
default.hash_stable(hcx, hasher);
221222
synthetic.hash_stable(hcx, hasher);
222-
attrs.hash_stable(hcx, hasher);
223223
}
224224
}
225225
}

0 commit comments

Comments
 (0)