Skip to content

Commit f680c62

Browse files
committed
mir: store the span of a scope in the ScopeData.
1 parent 4e6b178 commit f680c62

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/librustc/mir/repr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ impl ScopeId {
698698

699699
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
700700
pub struct ScopeData {
701+
pub span: Span,
701702
pub parent_scope: Option<ScopeId>,
702703
}
703704

src/librustc/mir/visit.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,11 @@ macro_rules! make_mir_visitor {
298298
fn super_scope_data(&mut self,
299299
scope_data: & $($mutability)* ScopeData) {
300300
let ScopeData {
301+
ref $($mutability)* span,
301302
ref $($mutability)* parent_scope,
302303
} = *scope_data;
303304

305+
self.visit_span(span);
304306
if let Some(ref $($mutability)* parent_scope) = *parent_scope {
305307
self.visit_scope_id(parent_scope);
306308
}

src/librustc_mir/build/scope.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ impl<'a,'tcx> Builder<'a,'tcx> {
255255
debug!("push_scope({:?})", extent);
256256
let parent_id = self.scopes.last().map(|s| s.id);
257257
let id = ScopeId::new(self.scope_datas.len());
258+
let tcx = self.hir.tcx();
258259
self.scope_datas.push(ScopeData {
260+
span: extent.span(&tcx.region_maps, &tcx.map).unwrap_or(DUMMY_SP),
259261
parent_scope: parent_id,
260262
});
261263
self.scopes.push(Scope {

0 commit comments

Comments
 (0)