Skip to content

Coherence rules are stricter than they need to be #5514

Closed
@nikomatsakis

Description

@nikomatsakis

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>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions