Skip to content

Commit 13f8c82

Browse files
committed
Fixed off-by-one spans in MIR borrowck errors.
1 parent 839ff6f commit 13f8c82

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/librustc_mir/build/scope.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
695695
if let DropKind::Value { .. } = drop_kind {
696696
scope.needs_cleanup = true;
697697
}
698+
698699
let region_scope_span = region_scope.span(self.hir.tcx(),
699700
&self.hir.region_scope_tree);
700-
// Attribute scope exit drops to scope's closing brace
701-
let scope_end = region_scope_span.with_lo(region_scope_span.hi());
701+
// Attribute scope exit drops to scope's closing brace.
702+
// Without this check when finding the endpoint, we'll run into an ICE.
703+
let scope_end = if region_scope_span.hi().0 == 0 {
704+
region_scope_span
705+
} else {
706+
region_scope_span.end_point()
707+
};
708+
702709
scope.drops.push(DropData {
703710
span: scope_end,
704711
location: place.clone(),

0 commit comments

Comments
 (0)