@@ -19,7 +19,7 @@ use rustc_middle::ty::layout::ValidityRequirement;
1919use rustc_middle:: ty:: {
2020 self , AdtDef , AliasTy , AssocItem , AssocKind , Binder , BoundRegion , FnSig , GenericArg , GenericArgKind ,
2121 GenericArgsRef , GenericParamDefKind , IntTy , ParamEnv , Region , RegionKind , TraitRef , Ty , TyCtxt , TypeSuperVisitable ,
22- TypeVisitable , TypeVisitableExt , TypeVisitor , TypingMode , UintTy , Upcast , VariantDef , VariantDiscr ,
22+ TypeVisitable , TypeVisitableExt , TypeVisitor , UintTy , Upcast , VariantDef , VariantDiscr ,
2323} ;
2424use rustc_span:: symbol:: Ident ;
2525use rustc_span:: { DUMMY_SP , Span , Symbol , sym} ;
@@ -226,7 +226,7 @@ pub fn implements_trait<'tcx>(
226226 trait_id : DefId ,
227227 args : & [ GenericArg < ' tcx > ] ,
228228) -> bool {
229- implements_trait_with_env_from_iter ( cx. tcx , cx. param_env , ty, trait_id, None , args. iter ( ) . map ( |& x| Some ( x) ) )
229+ implements_trait_with_env_from_iter ( cx. tcx , cx. typing_env ( ) , ty, trait_id, None , args. iter ( ) . map ( |& x| Some ( x) ) )
230230}
231231
232232/// Same as `implements_trait` but allows using a `ParamEnv` different from the lint context.
@@ -235,19 +235,19 @@ pub fn implements_trait<'tcx>(
235235/// environment, used for checking const traits.
236236pub fn implements_trait_with_env < ' tcx > (
237237 tcx : TyCtxt < ' tcx > ,
238- param_env : ParamEnv < ' tcx > ,
238+ typing_env : ty :: TypingEnv < ' tcx > ,
239239 ty : Ty < ' tcx > ,
240240 trait_id : DefId ,
241241 callee_id : Option < DefId > ,
242242 args : & [ GenericArg < ' tcx > ] ,
243243) -> bool {
244- implements_trait_with_env_from_iter ( tcx, param_env , ty, trait_id, callee_id, args. iter ( ) . map ( |& x| Some ( x) ) )
244+ implements_trait_with_env_from_iter ( tcx, typing_env , ty, trait_id, callee_id, args. iter ( ) . map ( |& x| Some ( x) ) )
245245}
246246
247247/// Same as `implements_trait_from_env` but takes the arguments as an iterator.
248248pub fn implements_trait_with_env_from_iter < ' tcx > (
249249 tcx : TyCtxt < ' tcx > ,
250- param_env : ParamEnv < ' tcx > ,
250+ typing_env : ty :: TypingEnv < ' tcx > ,
251251 ty : Ty < ' tcx > ,
252252 trait_id : DefId ,
253253 callee_id : Option < DefId > ,
@@ -268,7 +268,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
268268 return false ;
269269 }
270270
271- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: from_param_env ( param_env ) ) ;
271+ let ( infcx, param_env ) = tcx. infer_ctxt ( ) . build_with_typing_env ( typing_env ) ;
272272 let args = args
273273 . into_iter ( )
274274 . map ( |arg| arg. into ( ) . unwrap_or_else ( || infcx. next_ty_var ( DUMMY_SP ) . into ( ) ) )
@@ -1239,12 +1239,12 @@ impl<'tcx> InteriorMut<'tcx> {
12391239
12401240pub fn make_normalized_projection_with_regions < ' tcx > (
12411241 tcx : TyCtxt < ' tcx > ,
1242- param_env : ParamEnv < ' tcx > ,
1242+ typing_env : ty :: TypingEnv < ' tcx > ,
12431243 container_id : DefId ,
12441244 assoc_ty : Symbol ,
12451245 args : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
12461246) -> Option < Ty < ' tcx > > {
1247- fn helper < ' tcx > ( tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > , ty : AliasTy < ' tcx > ) -> Option < Ty < ' tcx > > {
1247+ fn helper < ' tcx > ( tcx : TyCtxt < ' tcx > , typing_env : ty :: TypingEnv < ' tcx > , ty : AliasTy < ' tcx > ) -> Option < Ty < ' tcx > > {
12481248 #[ cfg( debug_assertions) ]
12491249 if let Some ( ( i, arg) ) = ty
12501250 . args
@@ -1261,10 +1261,8 @@ pub fn make_normalized_projection_with_regions<'tcx>(
12611261 return None ;
12621262 }
12631263 let cause = ObligationCause :: dummy ( ) ;
1264- match tcx
1265- . infer_ctxt ( )
1266- . build ( TypingMode :: from_param_env ( param_env) )
1267- . at ( & cause, param_env)
1264+ let ( infcx, param_env) = tcx. infer_ctxt ( ) . build_with_typing_env ( typing_env) ;
1265+ match infcx. at ( & cause, param_env)
12681266 . query_normalize ( Ty :: new_projection_from_args ( tcx, ty. def_id , ty. args ) )
12691267 {
12701268 Ok ( ty) => Some ( ty. value ) ,
@@ -1274,20 +1272,13 @@ pub fn make_normalized_projection_with_regions<'tcx>(
12741272 } ,
12751273 }
12761274 }
1277- helper ( tcx, param_env , make_projection ( tcx, container_id, assoc_ty, args) ?)
1275+ helper ( tcx, typing_env , make_projection ( tcx, container_id, assoc_ty, args) ?)
12781276}
12791277
1280- pub fn normalize_with_regions < ' tcx > ( tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1278+ pub fn normalize_with_regions < ' tcx > ( tcx : TyCtxt < ' tcx > , typing_env : ty :: TypingEnv < ' tcx > , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
12811279 let cause = ObligationCause :: dummy ( ) ;
1282- match tcx
1283- . infer_ctxt ( )
1284- . build ( TypingMode :: from_param_env ( param_env) )
1285- . at ( & cause, param_env)
1286- . query_normalize ( ty)
1287- {
1288- Ok ( ty) => ty. value ,
1289- Err ( _) => ty,
1290- }
1280+ let ( infcx, param_env) = tcx. infer_ctxt ( ) . build_with_typing_env ( typing_env) ;
1281+ infcx. at ( & cause, param_env) . query_normalize ( ty) . map_or ( ty, |ty| ty. value )
12911282}
12921283
12931284/// Checks if the type is `core::mem::ManuallyDrop<_>`
0 commit comments