Skip to content

Fix example in orphan rule rationale #1960

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Imberflur
Copy link

The orphan rule doesn't prevent the case of impl<T: Display> MyTrait for T from breaking downstream. That would involve preventing downstream impls even on local downstream types. What it does prevent is downstream impls on generic types from a library.

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 14, 2025
@@ -178,7 +178,7 @@ The *orphan rule* states that a trait implementation is only allowed if either t

An orphan implementation is one that implements a foreign trait for a foreign type. If these were freely allowed, two crates could implement the same trait for the same type in incompatible ways, creating a situation where adding or updating a dependency could break compilation due to conflicting implementations.

The orphan rule enables library authors to add new implementations to their traits without fear that they'll break downstream code. Without these restrictions, a library couldn't add an implementation like `impl<T: Display> MyTrait for T` without potentially conflicting with downstream implementations.
The orphan rule enables library authors to add new implementations to their traits without fear that they'll break downstream code. Without these restrictions, a library couldn't add an implementation like `impl<T: Display> Trait for LocalGenericType<T>` without potentially conflicting with downstream implementations.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The orphan rule enables library authors to add new implementations to their traits without fear that they'll break downstream code. Without these restrictions, a library couldn't add an implementation like `impl<T: Display> Trait for LocalGenericType<T>` without potentially conflicting with downstream implementations.
The orphan rule enables library authors to add new implementations to their traits without fear that they'll break downstream code. With these restrictions, a library can add an implementation like `impl<T: Display> Trait for LocalGenericType<T>` without potentially conflicting with downstream implementations.

Thinking about removing the double negative here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants