# Slight relaxation of the orphan rules

**URL:** <https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718>\
**Category:** language design\
**Created:** [April 8, 2025, 11:14pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718 "2025-04-08T23:14:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jules-Bertholet](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jules-bertholet/32/10671_2.png) [@Jules-Bertholet](https://internals.rust-lang.org/u/Jules-Bertholet)\
**Post date:** [April 8, 2025, 11:14pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/1 "2025-04-08T23:14:18Z")

</div>

The orphan rules currently forbid trait impls of this form:

```rust
impl<T: LocalTrait> ForeignTrait for T { /* ... */ }

```

But, we could allow it without risking incoherence as long as the crate only implements `LocalTrait` for local types.

---

<div class="post-metadata">

**Author:** ![CAD97](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/cad97/32/3460_2.png) [@CAD97](https://internals.rust-lang.org/u/CAD97)\
**Post date:** [April 8, 2025, 11:52pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/2 "2025-04-08T23:52:02Z")

</div>

It would have the same pitfalls as a blanket impl `impl<T> LocalTrait for T`, of course, meaning that such an impl can't be added except in the version that introduces `LocalTrait`, but this does seem reasonably useful.

On the other hand, though, Rust generally prefers to avoid reasoning about involved impl disjointness, as that can easily introduce errors at a distance.

A different idea that I had previously is to introduce `#[fundamental] trait`, with the logical semantics being that _adding_ impls of the trait is considered a breaking change just like _removing_ an impl is. This means that a blanket impl over a fundamental trait can be treated for the purpose of coherence to be identical to an impl using each impl block for the fundamental trait. (Well, at least if it's also sealed; I haven't fully considered what coherence reasoning needs to look like when downstream crates can impl the fundamental trait for their types.)

---

<div class="post-metadata">

**Author:** ![quinedot](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/quinedot/32/7294_2.png) [@quinedot](https://internals.rust-lang.org/u/quinedot)\
**Post date:** [April 9, 2025, 12:38am UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/3 "2025-04-09T00:38:38Z")

</div>

> [@CAD97](#):
>
> A different idea that I had previously is to introduce `#[fundamental] trait`, with the logical semantics being that _adding_ impls of the trait is considered a breaking change just like _removing_ an impl is.

[That already exists (unstably);](https://rust-lang.github.io/rfcs/1023-rebalancing-coherence.html#errors-from-cargo-and-the-fundamental-attribute) `Sized` and the `Fn` traits are fundamental, and coherence takes that into account.

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/scottmcm/32/2355_2.png) [@scottmcm](https://internals.rust-lang.org/u/scottmcm)\
**Post date:** [April 9, 2025, 12:46am UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/4 "2025-04-09T00:46:29Z")

</div>

To go well this would also need to keep `LocalTrait` from having blanket impls from `OtherForeignTrait` and to keep other foreign crates from implementing `LocalTrait` on their own types, so I think it needs something on the trait too in order to allowed.

IIRC the `#[sealed] trait` discussions talked about potentially doing something like this.

---

<div class="post-metadata">

**Author:** ![Jules-Bertholet](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jules-bertholet/32/10671_2.png) [@Jules-Bertholet](https://internals.rust-lang.org/u/Jules-Bertholet)\
**Post date:** [April 9, 2025, 12:50am UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/5 "2025-04-09T00:50:34Z")

</div>

> [@scottmcm](#):
>
> and to keep other foreign crates from implementing `LocalTrait` on their own types

No, it should not prevent this. Downstream crates should be able to implement `LocalTrait` for their own types, as long as they don’t also provide a conflicting `ForeignTrait` impl. (As @CAD97 said, the `impl<T: LocalTrait> ForeignTrait for T` would be a breaking change to add except in the version that introduces `LocalTrait`, but that’s fine.)

---

<div class="post-metadata">

**Author:** ![Vorpal](https://avatars.discourse-cdn.com/v4/letter/v/aca169/32.png) [@Vorpal](https://internals.rust-lang.org/u/Vorpal)\
**Post date:** [April 14, 2025, 9:33pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/6 "2025-04-14T21:33:24Z")

</div>

There doesn't seem to be a tracking issue for stabilising `fundamental`. The linked issue from there is a closed issue about the problem, not the tracking issue.

Is it intended to be perma-unstable for some reason? If so why (I could see custom smart pointers wanting to opt in)?

---

<div class="post-metadata">

**Author:** ![quinedot](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/quinedot/32/7294_2.png) [@quinedot](https://internals.rust-lang.org/u/quinedot)\
**Post date:** [April 14, 2025, 9:46pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/7 "2025-04-14T21:46:44Z")

</div>

[This tracking issue exists,](https://github.com/rust-lang/rust/issues/29635) but I don't know the answers to your questions.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [October 6, 2026, 9:47pm UTC](https://internals.rust-lang.org/t/slight-relaxation-of-the-orphan-rules/22718/8 "2026-10-06T21:47:29Z")

</div>

Closed on October 6, 2026, 9:47pm UTC

This topic was automatically closed 540 days after the last reply. New replies are no longer allowed.
