Skip to content

Commit 50f5f60

Browse files
committed
unify last_span computation
1 parent 2f6aca8 commit 50f5f60

File tree

1 file changed

+7
-9
lines changed
  • compiler/rustc_borrowck/src/type_check

1 file changed

+7
-9
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,6 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
497497
for (block, block_data) in body.basic_blocks.iter_enumerated() {
498498
let mut location = Location { block, statement_index: 0 };
499499
for stmt in &block_data.statements {
500-
if !stmt.source_info.span.is_dummy() {
501-
self.last_span = stmt.source_info.span;
502-
}
503500
self.visit_statement(stmt, location);
504501
location.statement_index += 1;
505502
}
@@ -895,11 +892,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
895892
}
896893

897894
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
895+
fn visit_span(&mut self, span: Span) {
896+
if !span.is_dummy() {
897+
debug!(?span);
898+
self.last_span = span;
899+
}
900+
}
901+
898902
#[instrument(skip(self, body), level = "debug")]
899903
fn visit_body(&mut self, body: &Body<'tcx>) {
900904
debug_assert!(std::ptr::eq(self.body, body));
901-
self.last_span = body.span;
902-
debug!(?body.span);
903905

904906
for (local, local_decl) in body.local_decls.iter_enumerated() {
905907
self.visit_local_decl(local, local_decl);
@@ -908,9 +910,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
908910
for (block, block_data) in body.basic_blocks.iter_enumerated() {
909911
let mut location = Location { block, statement_index: 0 };
910912
for stmt in &block_data.statements {
911-
if !stmt.source_info.span.is_dummy() {
912-
self.last_span = stmt.source_info.span;
913-
}
914913
self.visit_statement(stmt, location);
915914
location.statement_index += 1;
916915
}
@@ -2098,7 +2097,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20982097

20992098
fn check_iscleanup(&mut self, block_data: &BasicBlockData<'tcx>) {
21002099
let is_cleanup = block_data.is_cleanup;
2101-
self.last_span = block_data.terminator().source_info.span;
21022100
match block_data.terminator().kind {
21032101
TerminatorKind::Goto { target } => {
21042102
self.assert_iscleanup(block_data, target, is_cleanup)

0 commit comments

Comments
 (0)