Skip to content

Commit 9b57e60

Browse files
committed
Use delay_span_bug for things that should be errors
1 parent c166ef9 commit 9b57e60

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustc_borrowck/borrowck/check_loans.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,14 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
416416
RegionKind::ReEarlyBound(..) |
417417
RegionKind::ReLateBound(..) |
418418
RegionKind::ReFree(..) |
419-
RegionKind::ReStatic => return,
419+
RegionKind::ReStatic => {
420+
self.bccx
421+
.tcx
422+
.sess.delay_span_bug(borrow_span,
423+
&format!("unexpected region for local data {:?}",
424+
loan_region));
425+
return
426+
}
420427

421428
// These cannot exist in borrowck
422429
RegionKind::ReVar(..) |
@@ -430,9 +437,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
430437
let body_id = self.bccx.body.value.hir_id.local_id;
431438

432439
if self.bccx.region_scope_tree.containing_body(scope) != Some(body_id) {
433-
// We are borrowing a local data longer than it's storage.
440+
// We are borrowing local data longer than its storage.
434441
// This should result in other borrowck errors.
435-
// FIXME: Ensure an error is generated
442+
self.bccx.tcx.sess.delay_span_bug(borrow_span,
443+
"borrowing local data longer than its storage");
436444
return;
437445
}
438446

0 commit comments

Comments
 (0)