@@ -172,11 +172,10 @@ pub fn implements_trait_with_env<'tcx>(
172172 return false ;
173173 }
174174 let ty_params = tcx. mk_substs ( ty_params. iter ( ) ) ;
175- tcx. infer_ctxt ( ) . enter ( |infcx| {
176- infcx
177- . type_implements_trait ( trait_id, ty, ty_params, param_env)
178- . must_apply_modulo_regions ( )
179- } )
175+ let infcx = tcx. infer_ctxt ( ) . build ( ) ;
176+ infcx
177+ . type_implements_trait ( trait_id, ty, ty_params, param_env)
178+ . must_apply_modulo_regions ( )
180179}
181180
182181/// Checks whether this type implements `Drop`.
@@ -242,27 +241,26 @@ fn is_normalizable_helper<'tcx>(
242241 }
243242 // prevent recursive loops, false-negative is better than endless loop leading to stack overflow
244243 cache. insert ( ty, false ) ;
245- let result = cx. tcx . infer_ctxt ( ) . enter ( |infcx| {
246- let cause = rustc_middle:: traits:: ObligationCause :: dummy ( ) ;
247- if infcx. at ( & cause, param_env) . normalize ( ty) . is_ok ( ) {
248- match ty. kind ( ) {
249- ty:: Adt ( def, substs) => def. variants ( ) . iter ( ) . all ( |variant| {
250- variant
251- . fields
252- . iter ( )
253- . all ( |field| is_normalizable_helper ( cx, param_env, field. ty ( cx. tcx , substs) , cache) )
254- } ) ,
255- _ => ty. walk ( ) . all ( |generic_arg| match generic_arg. unpack ( ) {
256- GenericArgKind :: Type ( inner_ty) if inner_ty != ty => {
257- is_normalizable_helper ( cx, param_env, inner_ty, cache)
258- } ,
259- _ => true , // if inner_ty == ty, we've already checked it
260- } ) ,
261- }
262- } else {
263- false
244+ let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
245+ let cause = rustc_middle:: traits:: ObligationCause :: dummy ( ) ;
246+ let result = if infcx. at ( & cause, param_env) . normalize ( ty) . is_ok ( ) {
247+ match ty. kind ( ) {
248+ ty:: Adt ( def, substs) => def. variants ( ) . iter ( ) . all ( |variant| {
249+ variant
250+ . fields
251+ . iter ( )
252+ . all ( |field| is_normalizable_helper ( cx, param_env, field. ty ( cx. tcx , substs) , cache) )
253+ } ) ,
254+ _ => ty. walk ( ) . all ( |generic_arg| match generic_arg. unpack ( ) {
255+ GenericArgKind :: Type ( inner_ty) if inner_ty != ty => {
256+ is_normalizable_helper ( cx, param_env, inner_ty, cache)
257+ } ,
258+ _ => true , // if inner_ty == ty, we've already checked it
259+ } ) ,
264260 }
265- } ) ;
261+ } else {
262+ false
263+ } ;
266264 cache. insert ( ty, result) ;
267265 result
268266}
0 commit comments