]> git.lizzy.rs Git - rust.git/commitdiff
validate: use the correct reveal during opts
authorlcnr <rust@lcnr.de>
Thu, 8 Dec 2022 10:24:25 +0000 (11:24 +0100)
committerlcnr <rust@lcnr.de>
Thu, 8 Dec 2022 10:24:25 +0000 (11:24 +0100)
compiler/rustc_const_eval/src/transform/validate.rs
compiler/rustc_middle/src/mir/syntax.rs

index bf700d3122465c584b1d15efc54a71ffe1ab88e1..5c9263dc5e35d1f252f55dc3fc5d28f5591de84b 100644 (file)
@@ -2,6 +2,7 @@
 
 use rustc_data_structures::fx::FxHashSet;
 use rustc_index::bit_set::BitSet;
+use rustc_infer::traits::Reveal;
 use rustc_middle::mir::interpret::Scalar;
 use rustc_middle::mir::visit::NonUseContext::VarDebugInfo;
 use rustc_middle::mir::visit::{PlaceContext, Visitor};
@@ -44,8 +45,11 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
             return;
         }
         let def_id = body.source.def_id();
-        let param_env = tcx.param_env(def_id);
         let mir_phase = self.mir_phase;
+        let param_env = match mir_phase.reveal() {
+            Reveal::UserFacing => tcx.param_env(def_id),
+            Reveal::All => tcx.param_env_reveal_all_normalized(def_id),
+        };
 
         let always_live_locals = always_storage_live_locals(body);
         let storage_liveness = MaybeStorageLive::new(always_live_locals)
index 7d2a6bda56926cbe8030d3430e35478c30540cb0..988d27ba262c5fa1bb6c378bcff7c8b587f84190 100644 (file)
@@ -6,6 +6,7 @@
 use super::{BasicBlock, Constant, Field, Local, SwitchTargets, UserTypeProjection};
 
 use crate::mir::coverage::{CodeRegion, CoverageKind};
+use crate::traits::Reveal;
 use crate::ty::adjustment::PointerCast;
 use crate::ty::subst::SubstsRef;
 use crate::ty::{self, List, Ty};
@@ -100,6 +101,13 @@ pub fn name(&self) -> &'static str {
             MirPhase::Runtime(RuntimePhase::Optimized) => "runtime-optimized",
         }
     }
+
+    pub fn reveal(&self) -> Reveal {
+        match *self {
+            MirPhase::Built | MirPhase::Analysis(_) => Reveal::UserFacing,
+            MirPhase::Runtime(_) => Reveal::All,
+        }
+    }
 }
 
 /// See [`MirPhase::Analysis`].