Skip to content

Obviously overlapping blanket impls are accepted #157

@CheaterCodes

Description

@CheaterCodes

In the hope of progressing rust-lang/rust#20400, I stumbled across rust-lang/rfcs#1672.
Given this comment, I decided to properly investigate a-mir-formality.

As it turns out, the current overlap checks are very generous. I don't know whether this is intentional and I just misunderstood the purpose of this tool, or if it's an oversight, or simply incompleteness. In any case, the following test is currently accepted by a-mir-formality, and I personally think it should (obviously) not be:

[
    crate core {
        trait Foo { }

        trait Bar { }

        impl<ty T> Foo for T { }
        
        impl<ty T> Foo for T where T: Bar { }
    }
]

I also pushed this test blanket_overlap with the expected error output to a branch on my fork:
https://github.com/CheaterCodes/a-mir-formality/tree/overlap_test

It appears that currently, a-mir-formality is not considering that a downstream type may implement both of the above traits, instead it just determines that may_be_remote is provable false (which it isn't, if I understand this code correctly).

If my understanding so far is correct, I'll happily look into this more closely, but it seems like fairly major effort would be required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions