@@ -52,9 +52,16 @@ fn overlap(selcx: &mut SelectionContext,
5252 b_def_id : ast:: DefId )
5353 -> bool
5454{
55+ debug ! ( "overlap(a_def_id={}, b_def_id={})" ,
56+ a_def_id. repr( selcx. tcx( ) ) ,
57+ b_def_id. repr( selcx. tcx( ) ) ) ;
58+
5559 let ( a_trait_ref, a_obligations) = impl_trait_ref_and_oblig ( selcx, a_def_id) ;
5660 let ( b_trait_ref, b_obligations) = impl_trait_ref_and_oblig ( selcx, b_def_id) ;
5761
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+
5865 // Does `a <: b` hold? If not, no overlap.
5966 if let Err ( _) = infer:: mk_sub_poly_trait_refs ( selcx. infcx ( ) ,
6067 true ,
@@ -64,10 +71,20 @@ fn overlap(selcx: &mut SelectionContext,
6471 return false ;
6572 }
6673
74+ debug ! ( "overlap: subtraitref check succeeded" ) ;
75+
6776 // 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
7188}
7289
7390/// Instantiate fresh variables for all bound parameters of the impl
0 commit comments