@@ -225,17 +225,10 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
225225 tcx : TyCtxt < ' tcx > ,
226226 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
227227) -> :: rustc_middle:: mir:: interpret:: EvalToConstValueResult < ' tcx > {
228- // see comment in eval_to_allocation_raw_provider for what we're doing here
229- if key. param_env . reveal ( ) == Reveal :: All {
230- let mut key = key;
231- key. param_env = key. param_env . with_user_facing ( ) ;
232- match tcx. eval_to_const_value_raw ( key) {
233- // try again with reveal all as requested
234- Err ( ErrorHandled :: TooGeneric ( _) ) => { }
235- // deduplicate calls
236- other => return other,
237- }
238- }
228+ // Const eval always happens in Reveal::All mode in order to be able to use the hidden types of
229+ // opaque types. This is needed for trivial things like `size_of`, but also for using associated
230+ // types that are not specified in the opaque type.
231+ assert_eq ! ( key. param_env. reveal( ) , Reveal :: All ) ;
239232
240233 // We call `const_eval` for zero arg intrinsics, too, in order to cache their value.
241234 // Catch such calls and evaluate them instead of trying to load a constant's MIR.
@@ -265,24 +258,11 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
265258 tcx : TyCtxt < ' tcx > ,
266259 key : ty:: ParamEnvAnd < ' tcx , GlobalId < ' tcx > > ,
267260) -> :: rustc_middle:: mir:: interpret:: EvalToAllocationRawResult < ' tcx > {
268- // Because the constant is computed twice (once per value of `Reveal`), we are at risk of
269- // reporting the same error twice here. To resolve this, we check whether we can evaluate the
270- // constant in the more restrictive `Reveal::UserFacing`, which most likely already was
271- // computed. For a large percentage of constants that will already have succeeded. Only
272- // associated constants of generic functions will fail due to not enough monomorphization
273- // information being available.
274-
275- // In case we fail in the `UserFacing` variant, we just do the real computation.
276- if key. param_env . reveal ( ) == Reveal :: All {
277- let mut key = key;
278- key. param_env = key. param_env . with_user_facing ( ) ;
279- match tcx. eval_to_allocation_raw ( key) {
280- // try again with reveal all as requested
281- Err ( ErrorHandled :: TooGeneric ( _) ) => { }
282- // deduplicate calls
283- other => return other,
284- }
285- }
261+ // Const eval always happens in Reveal::All mode in order to be able to use the hidden types of
262+ // opaque types. This is needed for trivial things like `size_of`, but also for using associated
263+ // types that are not specified in the opaque type.
264+
265+ assert_eq ! ( key. param_env. reveal( ) , Reveal :: All ) ;
286266 if cfg ! ( debug_assertions) {
287267 // Make sure we format the instance even if we do not print it.
288268 // This serves as a regression test against an ICE on printing.
0 commit comments