@@ -43,7 +43,6 @@ use rustc_middle::ty::{
43
43
} ;
44
44
use rustc_span:: Span ;
45
45
use rustc_span:: symbol:: Symbol ;
46
- use rustc_type_ir:: solve:: Reveal ;
47
46
use snapshot:: undo_log:: InferCtxtUndoLogs ;
48
47
use tracing:: { debug, instrument} ;
49
48
use type_variable:: TypeVariableOrigin ;
@@ -265,11 +264,12 @@ pub struct InferCtxt<'tcx> {
265
264
lexical_region_resolutions : RefCell < Option < LexicalRegionResolutions < ' tcx > > > ,
266
265
267
266
/// Caches the results of trait selection. This cache is used
268
- /// for things that have to do with the parameters in scope .
269
- pub selection_cache : select:: SelectionCache < ' tcx > ,
267
+ /// for things that depends on inference variables or placeholders .
268
+ pub selection_cache : select:: SelectionCache < ' tcx , ty :: ParamEnv < ' tcx > > ,
270
269
271
- /// Caches the results of trait evaluation.
272
- pub evaluation_cache : select:: EvaluationCache < ' tcx > ,
270
+ /// Caches the results of trait evaluation. This cache is used
271
+ /// for things that depends on inference variables or placeholders.
272
+ pub evaluation_cache : select:: EvaluationCache < ' tcx , ty:: ParamEnv < ' tcx > > ,
273
273
274
274
/// The set of predicates on which errors have been reported, to
275
275
/// avoid reporting the same error twice.
@@ -624,22 +624,7 @@ impl<'tcx> InferCtxt<'tcx> {
624
624
}
625
625
626
626
#[ inline( always) ]
627
- pub fn typing_mode (
628
- & self ,
629
- param_env_for_debug_assertion : ty:: ParamEnv < ' tcx > ,
630
- ) -> TypingMode < ' tcx > {
631
- if cfg ! ( debug_assertions) {
632
- match ( param_env_for_debug_assertion. reveal ( ) , self . typing_mode ) {
633
- ( Reveal :: All , TypingMode :: PostAnalysis )
634
- | ( Reveal :: UserFacing , TypingMode :: Coherence | TypingMode :: Analysis { .. } ) => { }
635
- ( r, t) => unreachable ! ( "TypingMode x Reveal mismatch: {r:?} {t:?}" ) ,
636
- }
637
- }
638
- self . typing_mode
639
- }
640
-
641
- #[ inline( always) ]
642
- pub fn typing_mode_unchecked ( & self ) -> TypingMode < ' tcx > {
627
+ pub fn typing_mode ( & self ) -> TypingMode < ' tcx > {
643
628
self . typing_mode
644
629
}
645
630
@@ -1005,7 +990,7 @@ impl<'tcx> InferCtxt<'tcx> {
1005
990
1006
991
#[ inline( always) ]
1007
992
pub fn can_define_opaque_ty ( & self , id : impl Into < DefId > ) -> bool {
1008
- match self . typing_mode_unchecked ( ) {
993
+ match self . typing_mode ( ) {
1009
994
TypingMode :: Analysis { defining_opaque_types } => {
1010
995
id. into ( ) . as_local ( ) . is_some_and ( |def_id| defining_opaque_types. contains ( & def_id) )
1011
996
}
@@ -1290,7 +1275,7 @@ impl<'tcx> InferCtxt<'tcx> {
1290
1275
/// which contains the necessary information to use the trait system without
1291
1276
/// using canonicalization or carrying this inference context around.
1292
1277
pub fn typing_env ( & self , param_env : ty:: ParamEnv < ' tcx > ) -> ty:: TypingEnv < ' tcx > {
1293
- let typing_mode = match self . typing_mode ( param_env ) {
1278
+ let typing_mode = match self . typing_mode ( ) {
1294
1279
ty:: TypingMode :: Coherence => ty:: TypingMode :: Coherence ,
1295
1280
// FIXME(#132279): This erases the `defining_opaque_types` as it isn't possible
1296
1281
// to handle them without proper canonicalization. This means we may cause cycle
0 commit comments