Overlap rules
nikomatsakis opened this issue · comments
Niko Matsakis commented
We need to model the overlap rules (excluding, for now, specialization). These rules work roughly like this:
- For each impl I1 in the current crate...
- For each impl I2 of the same trait in any crate...
- Check whether I1 and I2 can be applied to the same types
- And check whether predicates I1 and I2 hold, modulo
#[fundamental]
and locality concerns as described in https://rust-lang.github.io/rfcs/1023-rebalancing-coherence.html and https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html
- For each impl I2 of the same trait in any crate...
Here is a list of work items:
Niko Matsakis commented
The branch 2022-08-coherence includes some preliminary work here:
It introduces an overlap check and checks that the various impls that are in scope do not have types that successfully unify.
However, it has some problems:
- it fails to detect two instances of the same impl and report an error
- it doesn't include the check for where-clauses that are not provable as true