Navigation Menu

Skip to content

Commit

Permalink
mir: store the span of a scope in the ScopeData.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 11, 2016
1 parent 4e6b178 commit f680c62
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc/mir/repr.rs
Expand Up @@ -698,6 +698,7 @@ impl ScopeId {

#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct ScopeData {
pub span: Span,
pub parent_scope: Option<ScopeId>,
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc/mir/visit.rs
Expand Up @@ -298,9 +298,11 @@ macro_rules! make_mir_visitor {
fn super_scope_data(&mut self,
scope_data: & $($mutability)* ScopeData) {
let ScopeData {
ref $($mutability)* span,
ref $($mutability)* parent_scope,
} = *scope_data;

self.visit_span(span);
if let Some(ref $($mutability)* parent_scope) = *parent_scope {
self.visit_scope_id(parent_scope);
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_mir/build/scope.rs
Expand Up @@ -255,7 +255,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
debug!("push_scope({:?})", extent);
let parent_id = self.scopes.last().map(|s| s.id);
let id = ScopeId::new(self.scope_datas.len());
let tcx = self.hir.tcx();
self.scope_datas.push(ScopeData {
span: extent.span(&tcx.region_maps, &tcx.map).unwrap_or(DUMMY_SP),
parent_scope: parent_id,
});
self.scopes.push(Scope {
Expand Down

0 comments on commit f680c62

Please sign in to comment.