@@ -19,7 +19,7 @@ use rustc_middle::ty::layout::ValidityRequirement;
19
19
use rustc_middle:: ty:: {
20
20
self , AdtDef , AliasTy , AssocItem , AssocKind , Binder , BoundRegion , FnSig , GenericArg , GenericArgKind ,
21
21
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 ,
23
23
} ;
24
24
use rustc_span:: symbol:: Ident ;
25
25
use rustc_span:: { DUMMY_SP , Span , Symbol , sym} ;
@@ -226,7 +226,7 @@ pub fn implements_trait<'tcx>(
226
226
trait_id : DefId ,
227
227
args : & [ GenericArg < ' tcx > ] ,
228
228
) -> 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) ) )
230
230
}
231
231
232
232
/// Same as `implements_trait` but allows using a `ParamEnv` different from the lint context.
@@ -235,19 +235,19 @@ pub fn implements_trait<'tcx>(
235
235
/// environment, used for checking const traits.
236
236
pub fn implements_trait_with_env < ' tcx > (
237
237
tcx : TyCtxt < ' tcx > ,
238
- param_env : ParamEnv < ' tcx > ,
238
+ typing_env : ty :: TypingEnv < ' tcx > ,
239
239
ty : Ty < ' tcx > ,
240
240
trait_id : DefId ,
241
241
callee_id : Option < DefId > ,
242
242
args : & [ GenericArg < ' tcx > ] ,
243
243
) -> 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) ) )
245
245
}
246
246
247
247
/// Same as `implements_trait_from_env` but takes the arguments as an iterator.
248
248
pub fn implements_trait_with_env_from_iter < ' tcx > (
249
249
tcx : TyCtxt < ' tcx > ,
250
- param_env : ParamEnv < ' tcx > ,
250
+ typing_env : ty :: TypingEnv < ' tcx > ,
251
251
ty : Ty < ' tcx > ,
252
252
trait_id : DefId ,
253
253
callee_id : Option < DefId > ,
@@ -268,7 +268,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
268
268
return false ;
269
269
}
270
270
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 ) ;
272
272
let args = args
273
273
. into_iter ( )
274
274
. map ( |arg| arg. into ( ) . unwrap_or_else ( || infcx. next_ty_var ( DUMMY_SP ) . into ( ) ) )
@@ -1239,12 +1239,12 @@ impl<'tcx> InteriorMut<'tcx> {
1239
1239
1240
1240
pub fn make_normalized_projection_with_regions < ' tcx > (
1241
1241
tcx : TyCtxt < ' tcx > ,
1242
- param_env : ParamEnv < ' tcx > ,
1242
+ typing_env : ty :: TypingEnv < ' tcx > ,
1243
1243
container_id : DefId ,
1244
1244
assoc_ty : Symbol ,
1245
1245
args : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
1246
1246
) -> 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 > > {
1248
1248
#[ cfg( debug_assertions) ]
1249
1249
if let Some ( ( i, arg) ) = ty
1250
1250
. args
@@ -1261,10 +1261,8 @@ pub fn make_normalized_projection_with_regions<'tcx>(
1261
1261
return None ;
1262
1262
}
1263
1263
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)
1268
1266
. query_normalize ( Ty :: new_projection_from_args ( tcx, ty. def_id , ty. args ) )
1269
1267
{
1270
1268
Ok ( ty) => Some ( ty. value ) ,
@@ -1274,20 +1272,13 @@ pub fn make_normalized_projection_with_regions<'tcx>(
1274
1272
} ,
1275
1273
}
1276
1274
}
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) ?)
1278
1276
}
1279
1277
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 > {
1281
1279
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 )
1291
1282
}
1292
1283
1293
1284
/// Checks if the type is `core::mem::ManuallyDrop<_>`
0 commit comments