Skip to content

Commit a6bde67

Browse files
committed
hir: add hir_id to hir::Lifetime
1 parent a651777 commit a6bde67

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/librustc/hir/lowering.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<'a> LoweringContext<'a> {
713713
let params = lifetimes_to_define
714714
.into_iter()
715715
.map(|(span, hir_name)| {
716-
let def_node_id = self.next_id().node_id;
716+
let LoweredNodeId { node_id, hir_id } = self.next_id();
717717

718718
// Get the name we'll use to make the def-path. Note
719719
// that collisions are ok here and this shouldn't
@@ -1477,8 +1477,11 @@ impl<'a> LoweringContext<'a> {
14771477
&& !self.already_defined_lifetimes.contains(&name) {
14781478
self.already_defined_lifetimes.insert(name);
14791479

1480+
let LoweredNodeId { node_id, hir_id } = self.context.next_id();
1481+
14801482
self.output_lifetimes.push(hir::GenericArg::Lifetime(hir::Lifetime {
1481-
id: self.context.next_id().node_id,
1483+
id: node_id,
1484+
hir_id,
14821485
span: lifetime.span,
14831486
name,
14841487
}));
@@ -2282,8 +2285,10 @@ impl<'a> LoweringContext<'a> {
22822285
];
22832286

22842287
if let Some((name, span)) = bound_lifetime {
2288+
let LoweredNodeId { node_id, hir_id } = this.next_id();
2289+
22852290
bounds.push(hir::GenericBound::Outlives(
2286-
hir::Lifetime { id: this.next_id().node_id, name, span }));
2291+
hir::Lifetime { id: node_id, hir_id, name, span }));
22872292
}
22882293

22892294
hir::HirVec::from(bounds)
@@ -2350,8 +2355,11 @@ impl<'a> LoweringContext<'a> {
23502355
span: Span,
23512356
name: hir::LifetimeName,
23522357
) -> hir::Lifetime {
2358+
let LoweredNodeId { node_id, hir_id } = self.lower_node_id(id);
2359+
23532360
hir::Lifetime {
2354-
id: self.lower_node_id(id).node_id,
2361+
id: node_id,
2362+
hir_id,
23552363
span,
23562364
name: name,
23572365
}
@@ -4957,8 +4965,11 @@ impl<'a> LoweringContext<'a> {
49574965
// `'f`.
49584966
AnonymousLifetimeMode::CreateParameter => {
49594967
let fresh_name = self.collect_fresh_in_band_lifetime(span);
4968+
let LoweredNodeId { node_id, hir_id } = self.next_id();
4969+
49604970
hir::Lifetime {
4961-
id: self.next_id().node_id,
4971+
id: node_id,
4972+
hir_id,
49624973
span,
49634974
name: hir::LifetimeName::Param(fresh_name),
49644975
}
@@ -5058,8 +5069,11 @@ impl<'a> LoweringContext<'a> {
50585069
}
50595070

50605071
fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime {
5072+
let LoweredNodeId { node_id, hir_id } = self.next_id();
5073+
50615074
hir::Lifetime {
5062-
id: self.next_id().node_id,
5075+
id: node_id,
5076+
hir_id,
50635077
span,
50645078
name: hir::LifetimeName::Implicit,
50655079
}

src/librustc/hir/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ impl fmt::Debug for Label {
156156
#[derive(Clone, RustcEncodable, RustcDecodable, Copy)]
157157
pub struct Lifetime {
158158
pub id: NodeId,
159+
pub hir_id: HirId,
159160
pub span: Span,
160161

161162
/// Either "'a", referring to a named lifetime definition,

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl_stable_hash_for!(struct hir::Label {
159159

160160
impl_stable_hash_for!(struct hir::Lifetime {
161161
id,
162+
hir_id,
162163
span,
163164
name
164165
});

src/librustdoc/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl<'a, 'tcx, 'rcx> DocContext<'a, 'tcx, 'rcx> {
209209

210210
args.push(hir::GenericArg::Lifetime(hir::Lifetime {
211211
id: ast::DUMMY_NODE_ID,
212+
hir_id: hir::DUMMY_HIR_ID,
212213
span: DUMMY_SP,
213214
name: hir::LifetimeName::Param(name),
214215
}));

0 commit comments

Comments
 (0)