Skip to content

Commit da8b6e2

Browse files
committed
rustc: remove redundant fn_id's from CodeExtentData.
1 parent 2da080e commit da8b6e2

File tree

5 files changed

+19
-30
lines changed

5 files changed

+19
-30
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,8 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a, 'tcx>> for ::middle::region::
441441
CodeExtentData::DestructionScope(node_id) => {
442442
node_id.hash_stable(hcx, hasher);
443443
}
444-
CodeExtentData::CallSiteScope { fn_id, body_id } |
445-
CodeExtentData::ParameterScope { fn_id, body_id } => {
446-
fn_id.hash_stable(hcx, hasher);
444+
CodeExtentData::CallSiteScope(body_id) |
445+
CodeExtentData::ParameterScope(body_id) => {
447446
body_id.hash_stable(hcx, hasher);
448447
}
449448
CodeExtentData::Remainder(block_remainder) => {

src/librustc/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
153153
};
154154
let scope_decorated_tag = match *scope {
155155
region::CodeExtentData::Misc(_) => tag,
156-
region::CodeExtentData::CallSiteScope { .. } => {
156+
region::CodeExtentData::CallSiteScope(_) => {
157157
"scope of call-site for function"
158158
}
159-
region::CodeExtentData::ParameterScope { .. } => {
159+
region::CodeExtentData::ParameterScope(_) => {
160160
"scope of function body"
161161
}
162162
region::CodeExtentData::DestructionScope(_) => {

src/librustc/middle/region.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ pub enum CodeExtentData {
107107

108108
// extent of the call-site for a function or closure (outlives
109109
// the parameters as well as the body).
110-
CallSiteScope { fn_id: ast::NodeId, body_id: ast::NodeId },
110+
CallSiteScope(hir::BodyId),
111111

112112
// extent of parameters passed to a function or closure (they
113113
// outlive its body)
114-
ParameterScope { fn_id: ast::NodeId, body_id: ast::NodeId },
114+
ParameterScope(hir::BodyId),
115115

116116
// extent of destructors for temporaries of node-id
117117
DestructionScope(ast::NodeId),
@@ -157,8 +157,8 @@ impl CodeExtentData {
157157
// precise extent denoted by `self`.
158158
CodeExtentData::Remainder(br) => br.block,
159159
CodeExtentData::DestructionScope(node_id) => node_id,
160-
CodeExtentData::CallSiteScope { fn_id: _, body_id } |
161-
CodeExtentData::ParameterScope { fn_id: _, body_id } => body_id,
160+
CodeExtentData::CallSiteScope(body_id) |
161+
CodeExtentData::ParameterScope(body_id) => body_id.node_id,
162162
}
163163
}
164164

@@ -169,8 +169,8 @@ impl CodeExtentData {
169169
match hir_map.find(self.node_id()) {
170170
Some(hir_map::NodeBlock(ref blk)) => {
171171
match *self {
172-
CodeExtentData::CallSiteScope { .. } |
173-
CodeExtentData::ParameterScope { .. } |
172+
CodeExtentData::CallSiteScope(_) |
173+
CodeExtentData::ParameterScope(_) |
174174
CodeExtentData::Misc(_) |
175175
CodeExtentData::DestructionScope(_) => Some(blk.span),
176176

@@ -627,10 +627,7 @@ impl<'tcx> RegionMaps<'tcx> {
627627
self.root_body.unwrap()
628628
});
629629

630-
tcx.intern_code_extent(CodeExtentData::CallSiteScope {
631-
fn_id: tcx.hir.body_owner(body_id),
632-
body_id: body_id.node_id
633-
})
630+
tcx.intern_code_extent(CodeExtentData::CallSiteScope(body_id))
634631
}
635632

636633
/// Assuming that the provided region was defined within this `RegionMaps`,
@@ -651,10 +648,7 @@ impl<'tcx> RegionMaps<'tcx> {
651648
let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap();
652649
let body_id = tcx.hir.body_owned_by(param_owner_id);
653650

654-
tcx.intern_code_extent(CodeExtentData::CallSiteScope {
655-
fn_id: tcx.hir.body_owner(body_id),
656-
body_id: body_id.node_id
657-
})
651+
tcx.intern_code_extent(CodeExtentData::CallSiteScope(body_id))
658652
}
659653
}
660654

@@ -1172,9 +1166,9 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionResolutionVisitor<'a, 'tcx> {
11721166
self.cx.root_id = Some(body_id.node_id);
11731167

11741168
self.cx.parent = Some(self.new_code_extent(
1175-
CodeExtentData::CallSiteScope { fn_id: owner_id, body_id: body_id.node_id }));
1169+
CodeExtentData::CallSiteScope(body_id)));
11761170
self.cx.parent = Some(self.new_code_extent(
1177-
CodeExtentData::ParameterScope { fn_id: owner_id, body_id: body_id.node_id }));
1171+
CodeExtentData::ParameterScope(body_id)));
11781172

11791173
// The arguments and `self` are parented to the fn.
11801174
self.cx.var_parent = self.cx.parent.take();

src/librustc/ty/context.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,17 +656,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
656656
}
657657

658658
pub fn call_site_extent(self, fn_id: ast::NodeId) -> CodeExtent<'gcx> {
659-
self.intern_code_extent(CodeExtentData::CallSiteScope {
660-
fn_id,
661-
body_id: self.hir.body_owned_by(fn_id).node_id
662-
})
659+
self.intern_code_extent(CodeExtentData::CallSiteScope(
660+
self.hir.body_owned_by(fn_id)))
663661
}
664662

665663
pub fn parameter_extent(self, fn_id: ast::NodeId) -> CodeExtent<'gcx> {
666-
self.intern_code_extent(CodeExtentData::ParameterScope {
667-
fn_id,
668-
body_id: self.hir.body_owned_by(fn_id).node_id
669-
})
664+
self.intern_code_extent(CodeExtentData::ParameterScope(
665+
self.hir.body_owned_by(fn_id)))
670666
}
671667

672668
pub fn intern_code_extent(self, data: CodeExtentData) -> CodeExtent<'gcx> {

src/librustc_mir/build/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
416416
// We want `scopes[1]`, which is the `ParameterScope`.
417417
assert!(self.scopes.len() >= 2);
418418
assert!(match *self.scopes[1].extent {
419-
CodeExtentData::ParameterScope { .. } => true,
419+
CodeExtentData::ParameterScope(_) => true,
420420
_ => false,
421421
});
422422
self.scopes[1].extent

0 commit comments

Comments
 (0)