88use  hir:: LangItem ; 
99use  rustc_errors:: DelayDm ; 
1010use  rustc_hir as  hir; 
11- use  rustc_hir:: def_id:: DefId ; 
1211use  rustc_infer:: traits:: ObligationCause ; 
1312use  rustc_infer:: traits:: { Obligation ,  SelectionError ,  TraitObligation } ; 
1413use  rustc_lint_defs:: builtin:: DEREF_INTO_DYN_SUPERTRAIT ; 
@@ -707,7 +706,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
707706        ty :  Ty < ' tcx > , 
708707        param_env :  ty:: ParamEnv < ' tcx > , 
709708        cause :  & ObligationCause < ' tcx > , 
710-     )  -> Option < ( Ty < ' tcx > ,   DefId ) >  { 
709+     )  -> Option < ty :: PolyExistentialTraitRef < ' tcx > >  { 
711710        let  tcx = self . tcx ( ) ; 
712711        if  tcx. features ( ) . trait_upcasting  { 
713712            return  None ; 
@@ -729,27 +728,25 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
729728            return  None ; 
730729        } 
731730
732-         let  ty = traits:: normalize_projection_type ( 
733-             self , 
734-             param_env, 
735-             ty:: ProjectionTy  { 
736-                 item_def_id :  tcx. lang_items ( ) . deref_target ( ) ?, 
737-                 substs :  trait_ref. substs , 
738-             } , 
739-             cause. clone ( ) , 
740-             0 , 
741-             // We're *intentionally* throwing these away, 
742-             // since we don't actually use them. 
743-             & mut  vec ! [ ] , 
744-         ) 
745-         . ty ( ) 
746-         . unwrap ( ) ; 
747- 
748-         if  let  ty:: Dynamic ( data,  ..)  = ty. kind ( )  { 
749-             Some ( ( ty,  data. principal_def_id ( ) ?) ) 
750-         }  else  { 
751-             None 
752-         } 
731+         self . infcx . probe ( |_| { 
732+             let  ty = traits:: normalize_projection_type ( 
733+                 self , 
734+                 param_env, 
735+                 ty:: ProjectionTy  { 
736+                     item_def_id :  tcx. lang_items ( ) . deref_target ( ) ?, 
737+                     substs :  trait_ref. substs , 
738+                 } , 
739+                 cause. clone ( ) , 
740+                 0 , 
741+                 // We're *intentionally* throwing these away, 
742+                 // since we don't actually use them. 
743+                 & mut  vec ! [ ] , 
744+             ) 
745+             . ty ( ) 
746+             . unwrap ( ) ; 
747+ 
748+             if  let  ty:: Dynamic ( data,  ..)  = ty. kind ( )  {  data. principal ( )  }  else  {  None  } 
749+         } ) 
753750    } 
754751
755752    /// Searches for unsizing that might apply to `obligation`. 
@@ -811,21 +808,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
811808                        let  principal_a = data_a. principal ( ) . unwrap ( ) ; 
812809                        let  target_trait_did = principal_def_id_b. unwrap ( ) ; 
813810                        let  source_trait_ref = principal_a. with_self_ty ( self . tcx ( ) ,  source) ; 
814-                         if  let  Some ( ( deref_output_ty,  deref_output_trait_did) )  = self 
815-                             . need_migrate_deref_output_trait_object ( 
816-                                 source, 
817-                                 obligation. param_env , 
818-                                 & obligation. cause , 
819-                             ) 
820-                         { 
821-                             if  deref_output_trait_did == target_trait_did { 
811+                         if  let  Some ( deref_trait_ref)  = self . need_migrate_deref_output_trait_object ( 
812+                             source, 
813+                             obligation. param_env , 
814+                             & obligation. cause , 
815+                         )  { 
816+                             if  deref_trait_ref. def_id ( )  == target_trait_did { 
822817                                self . tcx ( ) . struct_span_lint_hir ( 
823818                                    DEREF_INTO_DYN_SUPERTRAIT , 
824819                                    obligation. cause . body_id , 
825820                                    obligation. cause . span , 
826821                                    DelayDm ( || format ! ( 
827822                                        "`{}` implements `Deref` with supertrait `{}` as output" , 
828-                                         source,  deref_output_ty 
823+                                         source,  deref_trait_ref 
829824                                    ) ) , 
830825                                    |lint| lint, 
831826                                ) ; 
0 commit comments