From 9e79e8776692fceebaebaa58014e14f9b77a4240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Fiala?= Date: Tue, 10 Oct 2023 14:21:41 +0200 Subject: [PATCH] Change constant lifetime analysis --- .../src/coupling_graph/context/region_info/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mir-state-analysis/src/coupling_graph/context/region_info/mod.rs b/mir-state-analysis/src/coupling_graph/context/region_info/mod.rs index 4cb4d78bee9..d6255e13ad8 100644 --- a/mir-state-analysis/src/coupling_graph/context/region_info/mod.rs +++ b/mir-state-analysis/src/coupling_graph/context/region_info/mod.rs @@ -185,8 +185,12 @@ impl<'tcx> Visitor<'tcx> for ConstantRegionCollector<'_, 'tcx> { self.super_rvalue(rvalue, location); if let Rvalue::Use(Operand::Constant(constant)) = rvalue { for r in constant.ty().walk().flat_map(|ga| ga.as_region()) { - assert!(r.is_var(), "{r:?} in {constant:?}"); - self.map.set(r.as_var(), RegionKind::ConstRef(false)); + // We may run into non-var regions here, e.g. assigning a const closure to a local where + // the closure captures state and thus that has e.g. `BrNamed` regions. + if r.is_var() { + // assert!(r.is_var(), "{r:?} in {constant:?} ({:?} at {location:?})", constant.ty()); + self.map.set(r.as_var(), RegionKind::ConstRef(false)); + } } } }