@@ -487,7 +487,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
487487 fn coerce_unsized ( & self , mut source : Ty < ' tcx > , mut target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
488488 source = self . shallow_resolve ( source) ;
489489 target = self . shallow_resolve ( target) ;
490- debug ! ( ?source, ?target) ;
490+ debug ! ( ?source, ?target, ? self . cause ) ;
491491
492492 // We don't apply any coercions incase either the source or target
493493 // aren't sufficiently well known but tend to instead just equate
@@ -565,11 +565,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
565565 let mut selcx = traits:: SelectionContext :: new ( self ) ;
566566
567567 // Create an obligation for `Source: CoerceUnsized<Target>`.
568- let cause = ObligationCause :: new (
569- self . cause . span ,
570- self . body_id ,
571- ObligationCauseCode :: Coercion { source, target } ,
572- ) ;
568+ let mut cause =
569+ ObligationCause :: new ( self . cause . span , self . body_id , self . cause . code ( ) . clone ( ) ) ;
570+ cause. map_code ( |parent_code| ObligationCauseCode :: Coercion { source, target, parent_code } ) ;
573571
574572 // Use a FIFO queue for this custom fulfillment procedure.
575573 //
@@ -993,8 +991,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
993991 }
994992 debug ! ( "coercion::try({:?}: {:?} -> {:?})" , expr, source, target) ;
995993
996- let cause =
997- cause. unwrap_or_else ( || self . cause ( expr. span , ObligationCauseCode :: ExprAssignable ) ) ;
994+ let cause = cause. unwrap_or_else ( || {
995+ self . cause ( expr. span , ObligationCauseCode :: ExprAssignable ( Some ( expr. hir_id ) ) )
996+ } ) ;
998997 let coerce = Coerce :: new ( self , cause, allow_two_phase) ;
999998 let ok = self . commit_if_ok ( |_| coerce. coerce ( source, target) ) ?;
1000999
@@ -1016,7 +1015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10161015 let source = self . resolve_vars_with_obligations ( expr_ty) ;
10171016 debug ! ( "coercion::can_with_predicates({:?} -> {:?})" , source, target) ;
10181017
1019- let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
1018+ let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ( None ) ) ;
10201019 // We don't ever need two-phase here since we throw out the result of the coercion
10211020 let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
10221021 self . probe ( |_| {
@@ -1033,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10331032 /// how many dereference steps needed to achieve `expr_ty <: target`. If
10341033 /// it's not possible, return `None`.
10351034 pub fn deref_steps ( & self , expr_ty : Ty < ' tcx > , target : Ty < ' tcx > ) -> Option < usize > {
1036- let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
1035+ let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ( None ) ) ;
10371036 // We don't ever need two-phase here since we throw out the result of the coercion
10381037 let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
10391038 coerce
0 commit comments