a-mir-formality icon indicating copy to clipboard operation
a-mir-formality copied to clipboard

Overlap rules

Open nikomatsakis opened this issue 3 years ago • 1 comments

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

Here is a list of work items:

  • [x] #90
  • [x] #88
  • [ ] Permit impls if the where-clauses are not provable, using the rules from re-balancing coherence
  • [ ] Support fundamental traits
  • [ ] Permit impls if the where-clauses have negative impls

nikomatsakis avatar Jun 25 '22 10:06 nikomatsakis

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

nikomatsakis avatar Aug 17 '22 18:08 nikomatsakis