Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coherence rules are stricter than they need to be #5514

Closed
nikomatsakis opened this issue Mar 23, 2013 · 2 comments
Closed

Coherence rules are stricter than they need to be #5514

nikomatsakis opened this issue Mar 23, 2013 · 2 comments
Labels
A-typesystem Area: The type system

Comments

@nikomatsakis
Copy link
Contributor

The current orphan rules in the coherence check are stricter than they need to be. For example, if I have

struct Foo

then I cannot have an impl like the following

impl ToStr for @Foo

The goal of the orphan rules is to guarantee that we can detect duplicate trait implementations so as to enforce coherence. To this end, it is only necessary to ensure that we could find any potentially conflicting impl. If we enforce the rule that the "for" type must "involve" some nominal type from the current crate, that is adequate for this purpose. For example @Foo should be ok but also Option<Foo>.

@nikomatsakis
Copy link
Contributor Author

I ran into this because I have a branch that implements Encodable for ty::t, but it doesn't work because this is *t_opaque

bors added a commit that referenced this issue Mar 23, 2013
@nikomatsakis
Copy link
Contributor Author

Fixed.

tesuji pushed a commit to tesuji/rustc that referenced this issue Jun 4, 2020
tesuji pushed a commit to tesuji/rustc that referenced this issue Jun 4, 2020
CONTRIBUTING: explain how to use cargo dev ra-setup

Fixes rust-lang#5514

Technically this should be merged after rust-lang/rust-clippy#5655 but it's not very important.

---

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

1 participant