@@ -487,7 +487,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
487
487
fn coerce_unsized ( & self , mut source : Ty < ' tcx > , mut target : Ty < ' tcx > ) -> CoerceResult < ' tcx > {
488
488
source = self . shallow_resolve ( source) ;
489
489
target = self . shallow_resolve ( target) ;
490
- debug ! ( ?source, ?target) ;
490
+ debug ! ( ?source, ?target, ? self . cause ) ;
491
491
492
492
// We don't apply any coercions incase either the source or target
493
493
// aren't sufficiently well known but tend to instead just equate
@@ -565,11 +565,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
565
565
let mut selcx = traits:: SelectionContext :: new ( self ) ;
566
566
567
567
// 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 } ) ;
573
571
574
572
// Use a FIFO queue for this custom fulfillment procedure.
575
573
//
@@ -993,8 +991,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
993
991
}
994
992
debug ! ( "coercion::try({:?}: {:?} -> {:?})" , expr, source, target) ;
995
993
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
+ } ) ;
998
997
let coerce = Coerce :: new ( self , cause, allow_two_phase) ;
999
998
let ok = self . commit_if_ok ( |_| coerce. coerce ( source, target) ) ?;
1000
999
@@ -1016,7 +1015,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1016
1015
let source = self . resolve_vars_with_obligations ( expr_ty) ;
1017
1016
debug ! ( "coercion::can_with_predicates({:?} -> {:?})" , source, target) ;
1018
1017
1019
- let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ) ;
1018
+ let cause = self . cause ( DUMMY_SP , ObligationCauseCode :: ExprAssignable ( None ) ) ;
1020
1019
// We don't ever need two-phase here since we throw out the result of the coercion
1021
1020
let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
1022
1021
self . probe ( |_| {
@@ -1033,7 +1032,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1033
1032
/// how many dereference steps needed to achieve `expr_ty <: target`. If
1034
1033
/// it's not possible, return `None`.
1035
1034
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 ) ) ;
1037
1036
// We don't ever need two-phase here since we throw out the result of the coercion
1038
1037
let coerce = Coerce :: new ( self , cause, AllowTwoPhase :: No ) ;
1039
1038
coerce
0 commit comments