@@ -408,14 +408,21 @@ fn impl_intersection_has_negative_obligation(
408408
409409 // Equate the headers to find their intersection (the general type, with infer vars,
410410 // that may apply both impls).
411- let Some ( _equate_obligations ) =
411+ let Some ( equate_obligations ) =
412412 equate_impl_headers ( infcx, param_env, & impl1_header, & impl2_header)
413413 else {
414414 return false ;
415415 } ;
416416
417417 plug_infer_with_placeholders ( infcx, universe, ( impl1_header. impl_args , impl2_header. impl_args ) ) ;
418418
419+ // FIXME(with_negative_coherence): the infcx has constraints from equating
420+ // the impl headers. We should use these constraints as assumptions, not as
421+ // requirements, when proving the negated where clauses below.
422+ drop ( equate_obligations) ;
423+ drop ( infcx. take_registered_region_obligations ( ) ) ;
424+ drop ( infcx. take_and_reset_region_constraints ( ) ) ;
425+
419426 util:: elaborate ( tcx, tcx. predicates_of ( impl2_def_id) . instantiate ( tcx, impl2_header. impl_args ) )
420427 . any ( |( clause, _) | try_prove_negated_where_clause ( infcx, clause, param_env) )
421428}
@@ -541,14 +548,6 @@ fn try_prove_negated_where_clause<'tcx>(
541548 return false ;
542549 } ;
543550
544- // FIXME(with_negative_coherence): the infcx has region contraints from equating
545- // the impl headers as requirements. Given that the only region constraints we
546- // get are involving inference regions in the root, it shouldn't matter, but
547- // still sus.
548- //
549- // We probably should just throw away the region obligations registered up until
550- // now, or ideally use them as assumptions when proving the region obligations
551- // that we get from proving the negative predicate below.
552551 let ref infcx = root_infcx. fork ( ) ;
553552 let ocx = ObligationCtxt :: new ( infcx) ;
554553
0 commit comments