@@ -9,7 +9,6 @@ use rustc_data_structures::unord::UnordSet;
99use rustc_infer:: infer:: DefineOpaqueTypes ;
1010use rustc_middle:: ty:: { Region , RegionVid } ;
1111use tracing:: debug;
12- use ty:: TypingMode ;
1312
1413use super :: * ;
1514use crate :: errors:: UnableToConstructConstantValue ;
@@ -71,15 +70,15 @@ impl<'tcx> AutoTraitFinder<'tcx> {
7170 pub fn find_auto_trait_generics < A > (
7271 & self ,
7372 ty : Ty < ' tcx > ,
74- orig_env : ty:: ParamEnv < ' tcx > ,
73+ typing_env : ty:: TypingEnv < ' tcx > ,
7574 trait_did : DefId ,
7675 mut auto_trait_callback : impl FnMut ( AutoTraitInfo < ' tcx > ) -> A ,
7776 ) -> AutoTraitResult < A > {
7877 let tcx = self . tcx ;
7978
8079 let trait_ref = ty:: TraitRef :: new ( tcx, trait_did, [ ty] ) ;
8180
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 ) ;
8382 let mut selcx = SelectionContext :: new ( & infcx) ;
8483 for polarity in [ ty:: PredicatePolarity :: Positive , ty:: PredicatePolarity :: Negative ] {
8584 let result = selcx. select ( & Obligation :: new (
@@ -89,17 +88,13 @@ impl<'tcx> AutoTraitFinder<'tcx> {
8988 ty:: TraitPredicate { trait_ref, polarity } ,
9089 ) ) ;
9190 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" ) ;
9792 // If an explicit impl exists, it always takes priority over an auto impl
9893 return AutoTraitResult :: ExplicitImpl ;
9994 }
10095 }
10196
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 ) ;
10398 let mut fresh_preds = FxIndexSet :: default ( ) ;
10499
105100 // Due to the way projections are handled by SelectionContext, we need to run
0 commit comments