8
8
use hir:: LangItem ;
9
9
use rustc_hir as hir;
10
10
use rustc_hir:: def_id:: DefId ;
11
- use rustc_infer:: traits:: TraitEngine ;
11
+ use rustc_infer:: traits:: ObligationCause ;
12
12
use rustc_infer:: traits:: { Obligation , SelectionError , TraitObligation } ;
13
13
use rustc_lint_defs:: builtin:: DEREF_INTO_DYN_SUPERTRAIT ;
14
14
use rustc_middle:: ty:: print:: with_no_trimmed_paths;
@@ -706,7 +706,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
706
706
fn need_migrate_deref_output_trait_object (
707
707
& mut self ,
708
708
ty : Ty < ' tcx > ,
709
- cause : & traits:: ObligationCause < ' tcx > ,
710
709
param_env : ty:: ParamEnv < ' tcx > ,
711
710
) -> Option < ( Ty < ' tcx > , DefId ) > {
712
711
let tcx = self . tcx ( ) ;
@@ -721,32 +720,35 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
721
720
} ;
722
721
723
722
let obligation = traits:: Obligation :: new (
724
- cause . clone ( ) ,
723
+ ObligationCause :: dummy ( ) ,
725
724
param_env,
726
725
ty:: Binder :: dummy ( trait_ref) . without_const ( ) . to_predicate ( tcx) ,
727
726
) ;
728
727
if !self . infcx . predicate_may_hold ( & obligation) {
729
728
return None ;
730
729
}
731
730
732
- let mut fulfillcx = traits:: FulfillmentContext :: new_in_snapshot ( ) ;
733
- let normalized_ty = fulfillcx. normalize_projection_type (
734
- & self . infcx ,
731
+ let ty = traits:: normalize_projection_type (
732
+ self ,
735
733
param_env,
736
734
ty:: ProjectionTy {
737
735
item_def_id : tcx. lang_items ( ) . deref_target ( ) ?,
738
736
substs : trait_ref. substs ,
739
737
} ,
740
- cause. clone ( ) ,
741
- ) ;
742
-
743
- let ty:: Dynamic ( data, ..) = normalized_ty. kind ( ) else {
744
- return None ;
745
- } ;
746
-
747
- let def_id = data. principal_def_id ( ) ?;
748
-
749
- return Some ( ( normalized_ty, def_id) ) ;
738
+ ObligationCause :: dummy ( ) ,
739
+ 0 ,
740
+ // We're *intentionally* throwing these away,
741
+ // since we don't actually use them.
742
+ & mut vec ! [ ] ,
743
+ )
744
+ . ty ( )
745
+ . unwrap ( ) ;
746
+
747
+ if let ty:: Dynamic ( data, ..) = ty. kind ( ) {
748
+ Some ( ( ty, data. principal_def_id ( ) ?) )
749
+ } else {
750
+ None
751
+ }
750
752
}
751
753
752
754
/// Searches for unsizing that might apply to `obligation`.
@@ -807,11 +809,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
807
809
let target_trait_did = principal_def_id_b. unwrap ( ) ;
808
810
let source_trait_ref = principal_a. with_self_ty ( self . tcx ( ) , source) ;
809
811
if let Some ( ( deref_output_ty, deref_output_trait_did) ) = self
810
- . need_migrate_deref_output_trait_object (
811
- source,
812
- & obligation. cause ,
813
- obligation. param_env ,
814
- )
812
+ . need_migrate_deref_output_trait_object ( source, obligation. param_env )
815
813
{
816
814
if deref_output_trait_did == target_trait_did {
817
815
self . tcx ( ) . struct_span_lint_hir (
0 commit comments