# Function rustc_trait_selection::traits::coherence::impl_intersection_has_impossible_obligation

source ·

    fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
        selcx: &mut SelectionContext<'cx, 'tcx>,
        obligations: &'a [PredicateObligation<'tcx>]
    ) -> IntersectionHasImpossibleObligations<'tcx>

Expand description

Check if both impls can be satisfied by a common type by considering whether any of either impl’s obligations is not known to hold.

For example, given these two impls: `impl From<MyLocalType> for Box<dyn Error>` (in my crate) `impl<E> From<E> for Box<dyn Error> where E: Error` (in libstd)

After replacing both impl headers with inference vars (which happens before this function is called), we get: `Box<dyn Error>: From<MyLocalType>` `Box<dyn Error>: From<?E>`

This gives us `?E = MyLocalType`. We then certainly know that `MyLocalType: Error` never holds in intercrate mode since a local impl does not exist, and a downstream impl cannot be added – therefore can consider the intersection of the two impls above to be empty.

Importantly, this works even if there isn’t a `impl !Error for MyLocalType`.