mir: store the span of a scope in the ScopeData.

This commit is contained in:
Eduard Burtescu 2016-04-06 17:17:12 +03:00
parent 4e6b178649
commit f680c623d4
3 changed files with 5 additions and 0 deletions

View File

@ -698,6 +698,7 @@ impl ScopeId {
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct ScopeData {
pub span: Span,
pub parent_scope: Option<ScopeId>,
}

View File

@ -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);
}

View File

@ -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 {