@@ -9,7 +9,7 @@ use rustc_macros::extension;
9
9
pub use rustc_middle:: traits:: query:: NormalizationResult ;
10
10
use rustc_middle:: ty:: fold:: { FallibleTypeFolder , TypeFoldable , TypeSuperFoldable } ;
11
11
use rustc_middle:: ty:: visit:: { TypeSuperVisitable , TypeVisitable , TypeVisitableExt } ;
12
- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitor } ;
12
+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitor , TypingMode } ;
13
13
use rustc_span:: DUMMY_SP ;
14
14
use tracing:: { debug, info, instrument} ;
15
15
@@ -21,7 +21,7 @@ use crate::infer::canonical::OriginalQueryValues;
21
21
use crate :: infer:: { InferCtxt , InferOk } ;
22
22
use crate :: traits:: normalize:: needs_normalization;
23
23
use crate :: traits:: {
24
- BoundVarReplacer , Normalized , ObligationCause , PlaceholderReplacer , Reveal , ScrubbedTraitError ,
24
+ BoundVarReplacer , Normalized , ObligationCause , PlaceholderReplacer , ScrubbedTraitError ,
25
25
} ;
26
26
27
27
#[ extension( pub trait QueryNormalizeExt <' tcx>) ]
@@ -215,10 +215,12 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> {
215
215
let res = match kind {
216
216
ty:: Opaque => {
217
217
// Only normalize `impl Trait` outside of type inference, usually in codegen.
218
- match self . param_env . reveal ( ) {
219
- Reveal :: UserFacing => ty. try_super_fold_with ( self ) ?,
218
+ match self . infcx . typing_mode ( self . param_env ) {
219
+ TypingMode :: Coherence | TypingMode :: Analysis { defining_opaque_types : _ } => {
220
+ ty. try_super_fold_with ( self ) ?
221
+ }
220
222
221
- Reveal :: All => {
223
+ TypingMode :: PostAnalysis => {
222
224
let args = data. args . try_fold_with ( self ) ?;
223
225
let recursion_limit = self . cx ( ) . recursion_limit ( ) ;
224
226
0 commit comments