@@ -266,7 +266,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
266
266
}
267
267
}
268
268
269
- if self . param_env . caller_bounds ( ) . iter ( ) . any ( |c| {
269
+ if self . infcx . param_env . caller_bounds ( ) . iter ( ) . any ( |c| {
270
270
c. as_trait_clause ( ) . is_some_and ( |pred| {
271
271
pred. skip_binder ( ) . self_ty ( ) == ty && self . infcx . tcx . is_fn_trait ( pred. def_id ( ) )
272
272
} )
@@ -682,13 +682,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
682
682
// Normalize before comparing to see through type aliases and projections.
683
683
let old_ty = ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, generic_args) ;
684
684
let new_ty = ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, new_args) ;
685
- if let Ok ( old_ty) =
686
- tcx . try_normalize_erasing_regions ( self . infcx . typing_env ( self . param_env ) , old_ty )
687
- && let Ok ( new_ty ) = tcx . try_normalize_erasing_regions (
688
- self . infcx . typing_env ( self . param_env ) ,
689
- new_ty ,
690
- )
691
- {
685
+ if let Ok ( old_ty) = tcx . try_normalize_erasing_regions (
686
+ self . infcx . typing_env ( self . infcx . param_env ) ,
687
+ old_ty ,
688
+ ) && let Ok ( new_ty ) = tcx . try_normalize_erasing_regions (
689
+ self . infcx . typing_env ( self . infcx . param_env ) ,
690
+ new_ty ,
691
+ ) {
692
692
old_ty == new_ty
693
693
} else {
694
694
false
@@ -707,15 +707,16 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
707
707
// Test the callee's predicates, substituting in `ref_ty` for the moved argument type.
708
708
clauses. instantiate ( tcx, new_args) . predicates . iter ( ) . all ( |& ( mut clause) | {
709
709
// Normalize before testing to see through type aliases and projections.
710
- if let Ok ( normalized) =
711
- tcx. try_normalize_erasing_regions ( self . infcx . typing_env ( self . param_env ) , clause)
712
- {
710
+ if let Ok ( normalized) = tcx. try_normalize_erasing_regions (
711
+ self . infcx . typing_env ( self . infcx . param_env ) ,
712
+ clause,
713
+ ) {
713
714
clause = normalized;
714
715
}
715
716
self . infcx . predicate_must_hold_modulo_regions ( & Obligation :: new (
716
717
tcx,
717
718
ObligationCause :: dummy ( ) ,
718
- self . param_env ,
719
+ self . infcx . param_env ,
719
720
clause,
720
721
) )
721
722
} )
@@ -904,7 +905,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
904
905
let ty = moved_place. ty ( self . body , self . infcx . tcx ) . ty ;
905
906
debug ! ( "ty: {:?}, kind: {:?}" , ty, ty. kind( ) ) ;
906
907
907
- let Some ( assign_value) = self . infcx . err_ctxt ( ) . ty_kind_suggestion ( self . param_env , ty)
908
+ let Some ( assign_value) = self . infcx . err_ctxt ( ) . ty_kind_suggestion ( self . infcx . param_env , ty)
908
909
else {
909
910
return ;
910
911
} ;
@@ -1304,7 +1305,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1304
1305
pub ( crate ) fn implements_clone ( & self , ty : Ty < ' tcx > ) -> bool {
1305
1306
let Some ( clone_trait_def) = self . infcx . tcx . lang_items ( ) . clone_trait ( ) else { return false } ;
1306
1307
self . infcx
1307
- . type_implements_trait ( clone_trait_def, [ ty] , self . param_env )
1308
+ . type_implements_trait ( clone_trait_def, [ ty] , self . infcx . param_env )
1308
1309
. must_apply_modulo_regions ( )
1309
1310
}
1310
1311
@@ -1437,7 +1438,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1437
1438
let ocx = ObligationCtxt :: new_with_diagnostics ( self . infcx ) ;
1438
1439
let cause = ObligationCause :: misc ( span, self . mir_def_id ( ) ) ;
1439
1440
1440
- ocx. register_bound ( cause, self . param_env , ty, def_id) ;
1441
+ ocx. register_bound ( cause, self . infcx . param_env , ty, def_id) ;
1441
1442
let errors = ocx. select_all_or_error ( ) ;
1442
1443
1443
1444
// Only emit suggestion if all required predicates are on generic
@@ -1957,7 +1958,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1957
1958
&& let ty:: Ref ( _, inner, _) = rcvr_ty. kind ( )
1958
1959
&& let inner = inner. peel_refs ( )
1959
1960
&& ( Holds { ty : inner } ) . visit_ty ( local_ty) . is_break ( )
1960
- && let None = self . infcx . type_implements_trait_shallow ( clone, inner, self . param_env )
1961
+ && let None =
1962
+ self . infcx . type_implements_trait_shallow ( clone, inner, self . infcx . param_env )
1961
1963
{
1962
1964
err. span_label (
1963
1965
span,
@@ -1989,7 +1991,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
1989
1991
let obligation = Obligation :: new (
1990
1992
self . infcx . tcx ,
1991
1993
ObligationCause :: dummy ( ) ,
1992
- self . param_env ,
1994
+ self . infcx . param_env ,
1993
1995
trait_ref,
1994
1996
) ;
1995
1997
self . infcx . err_ctxt ( ) . suggest_derive (
@@ -3398,7 +3400,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3398
3400
if let Some ( iter_trait) = tcx. get_diagnostic_item ( sym:: Iterator )
3399
3401
&& self
3400
3402
. infcx
3401
- . type_implements_trait ( iter_trait, [ return_ty] , self . param_env )
3403
+ . type_implements_trait ( iter_trait, [ return_ty] , self . infcx . param_env )
3402
3404
. must_apply_modulo_regions ( )
3403
3405
{
3404
3406
err. span_suggestion_hidden (
@@ -3839,14 +3841,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
3839
3841
tcx. get_diagnostic_item ( sym:: deref_target) . and_then ( |deref_target| {
3840
3842
Instance :: try_resolve (
3841
3843
tcx,
3842
- self . infcx . typing_env ( self . param_env ) ,
3844
+ self . infcx . typing_env ( self . infcx . param_env ) ,
3843
3845
deref_target,
3844
3846
method_args,
3845
3847
)
3846
3848
. transpose ( )
3847
3849
} ) ;
3848
3850
if let Some ( Ok ( instance) ) = deref_target {
3849
- let deref_target_ty = instance. ty ( tcx, self . infcx . typing_env ( self . param_env ) ) ;
3851
+ let deref_target_ty =
3852
+ instance. ty ( tcx, self . infcx . typing_env ( self . infcx . param_env ) ) ;
3850
3853
err. note ( format ! ( "borrow occurs due to deref coercion to `{deref_target_ty}`" ) ) ;
3851
3854
err. span_note ( tcx. def_span ( instance. def_id ( ) ) , "deref defined here" ) ;
3852
3855
}
0 commit comments