From 9b57e60f030e9a6b8b633e7ddfaaed611a8a9a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 11 Jan 2018 19:46:51 +0100 Subject: [PATCH] Use delay_span_bug for things that should be errors --- src/librustc_borrowck/borrowck/check_loans.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 7252a179539..862ea0c240a 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -416,7 +416,14 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { RegionKind::ReEarlyBound(..) | RegionKind::ReLateBound(..) | RegionKind::ReFree(..) | - RegionKind::ReStatic => return, + RegionKind::ReStatic => { + self.bccx + .tcx + .sess.delay_span_bug(borrow_span, + &format!("unexpected region for local data {:?}", + loan_region)); + return + } // These cannot exist in borrowck RegionKind::ReVar(..) | @@ -430,9 +437,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { let body_id = self.bccx.body.value.hir_id.local_id; if self.bccx.region_scope_tree.containing_body(scope) != Some(body_id) { - // We are borrowing a local data longer than it's storage. + // We are borrowing local data longer than its storage. // This should result in other borrowck errors. - // FIXME: Ensure an error is generated + self.bccx.tcx.sess.delay_span_bug(borrow_span, + "borrowing local data longer than its storage"); return; }