From cb4ebc1453a69145d6602de798dc704871a200da Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 5 Mar 2023 13:20:17 -0500 Subject: Check for free regions in MIR validation --- compiler/rustc_const_eval/src/transform/validate.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'compiler/rustc_const_eval') diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index fb37eb79a33..272fe3d1b31 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -72,6 +72,17 @@ impl<'tcx> MirPass<'tcx> for Validator { }; checker.visit_body(body); checker.check_cleanup_control_flow(); + + if let MirPhase::Runtime(_) = body.phase { + if let ty::InstanceDef::Item(_) = body.source.instance { + if body.has_free_regions() { + checker.fail( + Location::START, + format!("Free regions in optimized {} MIR", body.phase.name()), + ); + } + } + } } } -- cgit 1.4.1-3-g733a5