mirror of
https://github.com/rust-lang/rust
synced 2024-10-06 08:40:35 +00:00
rustc: remove redundant fn_id's from CodeExtentData.
This commit is contained in:
parent
2da080e779
commit
da8b6e276e
|
@ -441,9 +441,8 @@ fn hash_stable<W: StableHasherResult>(&self,
|
|||
CodeExtentData::DestructionScope(node_id) => {
|
||||
node_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
CodeExtentData::CallSiteScope { fn_id, body_id } |
|
||||
CodeExtentData::ParameterScope { fn_id, body_id } => {
|
||||
fn_id.hash_stable(hcx, hasher);
|
||||
CodeExtentData::CallSiteScope(body_id) |
|
||||
CodeExtentData::ParameterScope(body_id) => {
|
||||
body_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
CodeExtentData::Remainder(block_remainder) => {
|
||||
|
|
|
@ -153,10 +153,10 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
};
|
||||
let scope_decorated_tag = match *scope {
|
||||
region::CodeExtentData::Misc(_) => tag,
|
||||
region::CodeExtentData::CallSiteScope { .. } => {
|
||||
region::CodeExtentData::CallSiteScope(_) => {
|
||||
"scope of call-site for function"
|
||||
}
|
||||
region::CodeExtentData::ParameterScope { .. } => {
|
||||
region::CodeExtentData::ParameterScope(_) => {
|
||||
"scope of function body"
|
||||
}
|
||||
region::CodeExtentData::DestructionScope(_) => {
|
||||
|
|
|
@ -107,11 +107,11 @@ pub enum CodeExtentData {
|
|||
|
||||
// extent of the call-site for a function or closure (outlives
|
||||
// the parameters as well as the body).
|
||||
CallSiteScope { fn_id: ast::NodeId, body_id: ast::NodeId },
|
||||
CallSiteScope(hir::BodyId),
|
||||
|
||||
// extent of parameters passed to a function or closure (they
|
||||
// outlive its body)
|
||||
ParameterScope { fn_id: ast::NodeId, body_id: ast::NodeId },
|
||||
ParameterScope(hir::BodyId),
|
||||
|
||||
// extent of destructors for temporaries of node-id
|
||||
DestructionScope(ast::NodeId),
|
||||
|
@ -157,8 +157,8 @@ pub fn node_id(&self) -> ast::NodeId {
|
|||
// precise extent denoted by `self`.
|
||||
CodeExtentData::Remainder(br) => br.block,
|
||||
CodeExtentData::DestructionScope(node_id) => node_id,
|
||||
CodeExtentData::CallSiteScope { fn_id: _, body_id } |
|
||||
CodeExtentData::ParameterScope { fn_id: _, body_id } => body_id,
|
||||
CodeExtentData::CallSiteScope(body_id) |
|
||||
CodeExtentData::ParameterScope(body_id) => body_id.node_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,8 +169,8 @@ pub fn span(&self, hir_map: &hir_map::Map) -> Option<Span> {
|
|||
match hir_map.find(self.node_id()) {
|
||||
Some(hir_map::NodeBlock(ref blk)) => {
|
||||
match *self {
|
||||
CodeExtentData::CallSiteScope { .. } |
|
||||
CodeExtentData::ParameterScope { .. } |
|
||||
CodeExtentData::CallSiteScope(_) |
|
||||
CodeExtentData::ParameterScope(_) |
|
||||
CodeExtentData::Misc(_) |
|
||||
CodeExtentData::DestructionScope(_) => Some(blk.span),
|
||||
|
||||
|
@ -627,10 +627,7 @@ pub fn early_free_extent<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
self.root_body.unwrap()
|
||||
});
|
||||
|
||||
tcx.intern_code_extent(CodeExtentData::CallSiteScope {
|
||||
fn_id: tcx.hir.body_owner(body_id),
|
||||
body_id: body_id.node_id
|
||||
})
|
||||
tcx.intern_code_extent(CodeExtentData::CallSiteScope(body_id))
|
||||
}
|
||||
|
||||
/// Assuming that the provided region was defined within this `RegionMaps`,
|
||||
|
@ -651,10 +648,7 @@ pub fn free_extent<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, fr: &ty::FreeRe
|
|||
let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap();
|
||||
let body_id = tcx.hir.body_owned_by(param_owner_id);
|
||||
|
||||
tcx.intern_code_extent(CodeExtentData::CallSiteScope {
|
||||
fn_id: tcx.hir.body_owner(body_id),
|
||||
body_id: body_id.node_id
|
||||
})
|
||||
tcx.intern_code_extent(CodeExtentData::CallSiteScope(body_id))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1172,9 +1166,9 @@ fn visit_body(&mut self, body: &'tcx hir::Body) {
|
|||
self.cx.root_id = Some(body_id.node_id);
|
||||
|
||||
self.cx.parent = Some(self.new_code_extent(
|
||||
CodeExtentData::CallSiteScope { fn_id: owner_id, body_id: body_id.node_id }));
|
||||
CodeExtentData::CallSiteScope(body_id)));
|
||||
self.cx.parent = Some(self.new_code_extent(
|
||||
CodeExtentData::ParameterScope { fn_id: owner_id, body_id: body_id.node_id }));
|
||||
CodeExtentData::ParameterScope(body_id)));
|
||||
|
||||
// The arguments and `self` are parented to the fn.
|
||||
self.cx.var_parent = self.cx.parent.take();
|
||||
|
|
|
@ -656,17 +656,13 @@ pub fn node_extent(self, n: ast::NodeId) -> CodeExtent<'gcx> {
|
|||
}
|
||||
|
||||
pub fn call_site_extent(self, fn_id: ast::NodeId) -> CodeExtent<'gcx> {
|
||||
self.intern_code_extent(CodeExtentData::CallSiteScope {
|
||||
fn_id,
|
||||
body_id: self.hir.body_owned_by(fn_id).node_id
|
||||
})
|
||||
self.intern_code_extent(CodeExtentData::CallSiteScope(
|
||||
self.hir.body_owned_by(fn_id)))
|
||||
}
|
||||
|
||||
pub fn parameter_extent(self, fn_id: ast::NodeId) -> CodeExtent<'gcx> {
|
||||
self.intern_code_extent(CodeExtentData::ParameterScope {
|
||||
fn_id,
|
||||
body_id: self.hir.body_owned_by(fn_id).node_id
|
||||
})
|
||||
self.intern_code_extent(CodeExtentData::ParameterScope(
|
||||
self.hir.body_owned_by(fn_id)))
|
||||
}
|
||||
|
||||
pub fn intern_code_extent(self, data: CodeExtentData) -> CodeExtent<'gcx> {
|
||||
|
|
|
@ -416,7 +416,7 @@ pub fn extent_of_return_scope(&self) -> CodeExtent<'tcx> {
|
|||
// We want `scopes[1]`, which is the `ParameterScope`.
|
||||
assert!(self.scopes.len() >= 2);
|
||||
assert!(match *self.scopes[1].extent {
|
||||
CodeExtentData::ParameterScope { .. } => true,
|
||||
CodeExtentData::ParameterScope(_) => true,
|
||||
_ => false,
|
||||
});
|
||||
self.scopes[1].extent
|
||||
|
|
Loading…
Reference in a new issue