@@ -666,15 +666,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
666666 let tcx = self . infcx . tcx ;
667667
668668 // Find out if the predicates show that the type is a Fn or FnMut
669- let find_fn_kind_from_did =
670- |predicates : ty:: EarlyBinder < & [ ( ty:: Predicate < ' tcx > , Span ) ] > , substs| {
671- predicates. 0 . iter ( ) . find_map ( |( pred, _) | {
669+ let find_fn_kind_from_did = |predicates : ty:: EarlyBinder <
670+ & [ ( ty:: Predicate < ' tcx > , Span ) ] ,
671+ > ,
672+ substs| {
673+ predicates. 0 . iter ( ) . find_map ( |( pred, _) | {
672674 let pred = if let Some ( substs) = substs {
673675 predicates. rebind ( * pred) . subst ( tcx, substs) . kind ( ) . skip_binder ( )
674676 } else {
675677 pred. kind ( ) . skip_binder ( )
676678 } ;
677- if let ty:: PredicateKind :: Trait ( pred) = pred && pred. self_ty ( ) == ty {
679+ if let ty:: PredicateKind :: Clause ( ty :: Clause :: Trait ( pred) ) = pred && pred. self_ty ( ) == ty {
678680 if Some ( pred. def_id ( ) ) == tcx. lang_items ( ) . fn_trait ( ) {
679681 return Some ( hir:: Mutability :: Not ) ;
680682 } else if Some ( pred. def_id ( ) ) == tcx. lang_items ( ) . fn_mut_trait ( ) {
@@ -683,7 +685,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
683685 }
684686 None
685687 } )
686- } ;
688+ } ;
687689
688690 // If the type is opaque/param/closure, and it is Fn or FnMut, let's suggest (mutably)
689691 // borrowing the type, since `&mut F: FnMut` iff `F: FnMut` and similarly for `Fn`.
@@ -784,13 +786,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
784786 let predicates: Result < Vec < _ > , _ > = errors
785787 . into_iter ( )
786788 . map ( |err| match err. obligation . predicate . kind ( ) . skip_binder ( ) {
787- PredicateKind :: Trait ( predicate) => match predicate. self_ty ( ) . kind ( ) {
788- ty:: Param ( param_ty) => Ok ( (
789- generics. type_param ( param_ty, tcx) ,
790- predicate. trait_ref . print_only_trait_path ( ) . to_string ( ) ,
791- ) ) ,
792- _ => Err ( ( ) ) ,
793- } ,
789+ PredicateKind :: Clause ( ty:: Clause :: Trait ( predicate) ) => {
790+ match predicate. self_ty ( ) . kind ( ) {
791+ ty:: Param ( param_ty) => Ok ( (
792+ generics. type_param ( param_ty, tcx) ,
793+ predicate. trait_ref . print_only_trait_path ( ) . to_string ( ) ,
794+ ) ) ,
795+ _ => Err ( ( ) ) ,
796+ }
797+ }
794798 _ => Err ( ( ) ) ,
795799 } )
796800 . collect ( ) ;
0 commit comments