@@ -9,7 +9,6 @@ use rustc_data_structures::unord::UnordSet;
9
9
use rustc_infer:: infer:: DefineOpaqueTypes ;
10
10
use rustc_middle:: ty:: { Region , RegionVid } ;
11
11
use tracing:: debug;
12
- use ty:: TypingMode ;
13
12
14
13
use super :: * ;
15
14
use crate :: errors:: UnableToConstructConstantValue ;
@@ -71,15 +70,15 @@ impl<'tcx> AutoTraitFinder<'tcx> {
71
70
pub fn find_auto_trait_generics < A > (
72
71
& self ,
73
72
ty : Ty < ' tcx > ,
74
- orig_env : ty:: ParamEnv < ' tcx > ,
73
+ typing_env : ty:: TypingEnv < ' tcx > ,
75
74
trait_did : DefId ,
76
75
mut auto_trait_callback : impl FnMut ( AutoTraitInfo < ' tcx > ) -> A ,
77
76
) -> AutoTraitResult < A > {
78
77
let tcx = self . tcx ;
79
78
80
79
let trait_ref = ty:: TraitRef :: new ( tcx, trait_did, [ ty] ) ;
81
80
82
- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
81
+ let ( infcx, orig_env ) = tcx. infer_ctxt ( ) . build_with_typing_env ( typing_env ) ;
83
82
let mut selcx = SelectionContext :: new ( & infcx) ;
84
83
for polarity in [ ty:: PredicatePolarity :: Positive , ty:: PredicatePolarity :: Negative ] {
85
84
let result = selcx. select ( & Obligation :: new (
@@ -89,17 +88,13 @@ impl<'tcx> AutoTraitFinder<'tcx> {
89
88
ty:: TraitPredicate { trait_ref, polarity } ,
90
89
) ) ;
91
90
if let Ok ( Some ( ImplSource :: UserDefined ( _) ) ) = result {
92
- debug ! (
93
- "find_auto_trait_generics({:?}): \
94
- manual impl found, bailing out",
95
- trait_ref
96
- ) ;
91
+ debug ! ( "find_auto_trait_generics({trait_ref:?}): manual impl found, bailing out" ) ;
97
92
// If an explicit impl exists, it always takes priority over an auto impl
98
93
return AutoTraitResult :: ExplicitImpl ;
99
94
}
100
95
}
101
96
102
- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
97
+ let ( infcx, orig_env ) = tcx. infer_ctxt ( ) . build_with_typing_env ( typing_env ) ;
103
98
let mut fresh_preds = FxIndexSet :: default ( ) ;
104
99
105
100
// Due to the way projections are handled by SelectionContext, we need to run
0 commit comments