From 17f6b6810b4abdbeb4f493e497c13825fb0f6ad4 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 2 Oct 2017 22:40:51 +0200 Subject: [PATCH] Remove assertion that the argument to every `EndRegion` correspond to some dataflow-tracked borrow-data entry. Fix #44828 (The comment thread on the aforementioned issue discusses why its best to just remove this assertion.) --- src/librustc_mir/dataflow/impls/borrows.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 3f815ec83e3..f1fe6e79dfe 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -122,11 +122,11 @@ impl<'a, 'tcx> BitDenotation for Borrows<'a, 'tcx> { }); match stmt.kind { mir::StatementKind::EndRegion(region_scope) => { - let borrow_indexes = self.region_map.get(&ReScope(region_scope)).unwrap_or_else(|| { - panic!("could not find BorrowIndexs for region scope {:?}", region_scope); - }); - - for idx in borrow_indexes { sets.kill(&idx); } + if let Some(borrow_indexes) = self.region_map.get(&ReScope(region_scope)) { + for idx in borrow_indexes { sets.kill(&idx); } + } else { + // (if there is no entry, then there are no borrows to be tracked) + } } mir::StatementKind::Assign(_, ref rhs) => {