@@ -52,9 +52,16 @@ fn overlap(selcx: &mut SelectionContext,
52
52
b_def_id : ast:: DefId )
53
53
-> bool
54
54
{
55
+ debug ! ( "overlap(a_def_id={}, b_def_id={})" ,
56
+ a_def_id. repr( selcx. tcx( ) ) ,
57
+ b_def_id. repr( selcx. tcx( ) ) ) ;
58
+
55
59
let ( a_trait_ref, a_obligations) = impl_trait_ref_and_oblig ( selcx, a_def_id) ;
56
60
let ( b_trait_ref, b_obligations) = impl_trait_ref_and_oblig ( selcx, b_def_id) ;
57
61
62
+ debug ! ( "overlap: a_trait_ref={}" , a_trait_ref. repr( selcx. tcx( ) ) ) ;
63
+ debug ! ( "overlap: b_trait_ref={}" , b_trait_ref. repr( selcx. tcx( ) ) ) ;
64
+
58
65
// Does `a <: b` hold? If not, no overlap.
59
66
if let Err ( _) = infer:: mk_sub_poly_trait_refs ( selcx. infcx ( ) ,
60
67
true ,
@@ -64,10 +71,20 @@ fn overlap(selcx: &mut SelectionContext,
64
71
return false ;
65
72
}
66
73
74
+ debug ! ( "overlap: subtraitref check succeeded" ) ;
75
+
67
76
// Are any of the obligations unsatisfiable? If so, no overlap.
68
- a_obligations. iter ( )
69
- . chain ( b_obligations. iter ( ) )
70
- . all ( |o| selcx. evaluate_obligation ( o) )
77
+ let opt_failing_obligation =
78
+ a_obligations. iter ( )
79
+ . chain ( b_obligations. iter ( ) )
80
+ . find ( |o| !selcx. evaluate_obligation ( o) ) ;
81
+
82
+ if let Some ( failing_obligation) = opt_failing_obligation {
83
+ debug ! ( "overlap: obligation unsatisfiable {}" , failing_obligation. repr( selcx. tcx( ) ) ) ;
84
+ return false ;
85
+ }
86
+
87
+ true
71
88
}
72
89
73
90
/// Instantiate fresh variables for all bound parameters of the impl
0 commit comments