@@ -472,8 +472,13 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
472472 // The move occurred as one of the arguments to a function call. Is that
473473 // argument generic? `def_id` can't be a closure here, so using `fn_sig` is fine
474474 let arg_param = if self . infcx . tcx . def_kind ( def_id) . is_fn_like ( )
475- && let sig =
476- self . infcx . tcx . fn_sig ( def_id) . instantiate_identity ( ) . skip_binder ( )
475+ && let sig = self
476+ . infcx
477+ . tcx
478+ . fn_sig ( def_id)
479+ . instantiate_identity ( )
480+ . skip_normalization ( )
481+ . skip_binder ( )
477482 && let Some ( arg_ty) = sig. inputs ( ) . get ( pos + offset)
478483 && let ty:: Param ( arg_param) = arg_ty. kind ( )
479484 {
@@ -685,7 +690,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
685690 place_span : Span ,
686691 ) -> Option < ty:: Mutability > {
687692 let tcx = self . infcx . tcx ;
688- let sig = tcx. fn_sig ( callee_did) . instantiate_identity ( ) . skip_binder ( ) ;
693+ let sig = tcx. fn_sig ( callee_did) . instantiate_identity ( ) . skip_normalization ( ) . skip_binder ( ) ;
689694 let clauses = tcx. predicates_of ( callee_did) ;
690695
691696 let generic_args = match call_expr. kind {
@@ -703,7 +708,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
703708
704709 // First, is there at least one method on one of `param`'s trait bounds?
705710 // This keeps us from suggesting borrowing the argument to `mem::drop`, e.g.
706- if !clauses. instantiate_identity ( tcx) . predicates . iter ( ) . any ( |clause| {
711+ if !clauses. instantiate_identity ( tcx) . skip_normalization ( ) . predicates . iter ( ) . any ( |clause| {
707712 clause. as_trait_clause ( ) . is_some_and ( |tc| {
708713 tc. self_ty ( ) . skip_binder ( ) . is_param ( param. index )
709714 && tc. polarity ( ) == ty:: PredicatePolarity :: Positive
@@ -729,8 +734,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
729734 ) ) ;
730735 let can_subst = |ty : Ty < ' tcx > | {
731736 // Normalize before comparing to see through type aliases and projections.
732- let old_ty = ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, generic_args) ;
733- let new_ty = ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, new_args) ;
737+ let old_ty =
738+ ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, generic_args) . skip_normalization ( ) ;
739+ let new_ty =
740+ ty:: EarlyBinder :: bind ( ty) . instantiate ( tcx, new_args) . skip_normalization ( ) ;
734741 if let Ok ( old_ty) = tcx. try_normalize_erasing_regions (
735742 self . infcx . typing_env ( self . infcx . param_env ) ,
736743 old_ty,
@@ -754,21 +761,23 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
754761 }
755762
756763 // Test the callee's predicates, substituting in `ref_ty` for the moved argument type.
757- clauses. instantiate ( tcx, new_args) . predicates . iter ( ) . all ( |& ( mut clause) | {
758- // Normalize before testing to see through type aliases and projections.
759- if let Ok ( normalized) = tcx. try_normalize_erasing_regions (
760- self . infcx . typing_env ( self . infcx . param_env ) ,
761- clause,
762- ) {
763- clause = normalized;
764- }
765- self . infcx . predicate_must_hold_modulo_regions ( & Obligation :: new (
766- tcx,
767- ObligationCause :: dummy ( ) ,
768- self . infcx . param_env ,
769- clause,
770- ) )
771- } )
764+ clauses. instantiate ( tcx, new_args) . skip_normalization ( ) . predicates . iter ( ) . all (
765+ |& ( mut clause) | {
766+ // Normalize before testing to see through type aliases and projections.
767+ if let Ok ( normalized) = tcx. try_normalize_erasing_regions (
768+ self . infcx . typing_env ( self . infcx . param_env ) ,
769+ clause,
770+ ) {
771+ clause = normalized;
772+ }
773+ self . infcx . predicate_must_hold_modulo_regions ( & Obligation :: new (
774+ tcx,
775+ ObligationCause :: dummy ( ) ,
776+ self . infcx . param_env ,
777+ clause,
778+ ) )
779+ } ,
780+ )
772781 } ) {
773782 let place_desc = if let Some ( desc) = self . describe_place ( moved_place) {
774783 format ! ( "`{desc}`" )
@@ -4153,11 +4162,20 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
41534162 if is_closure {
41544163 None
41554164 } else {
4156- let ty = self . infcx . tcx . type_of ( self . mir_def_id ( ) ) . instantiate_identity ( ) ;
4165+ let ty = self
4166+ . infcx
4167+ . tcx
4168+ . type_of ( self . mir_def_id ( ) )
4169+ . instantiate_identity ( )
4170+ . skip_normalization ( ) ;
41574171 match ty. kind ( ) {
41584172 ty:: FnDef ( _, _) | ty:: FnPtr ( ..) => self . annotate_fn_sig (
41594173 self . mir_def_id ( ) ,
4160- self . infcx . tcx . fn_sig ( self . mir_def_id ( ) ) . instantiate_identity ( ) ,
4174+ self . infcx
4175+ . tcx
4176+ . fn_sig ( self . mir_def_id ( ) )
4177+ . instantiate_identity ( )
4178+ . skip_normalization ( ) ,
41614179 ) ,
41624180 _ => None ,
41634181 }
0 commit comments