Statement about impls in non-generic orphan rule diagnostic is incorrect and badly worded

Open Beginner friendly
#166,834 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@shamnad-sherief is already working on this.

Since Dec 2, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Search the rustc diagnostics for the E0117 wording shown in the issue and read the code that selects the non-generic trait diagnostic. Compare its wording with the generic orphan-rule diagnostic and the example in the issue. Done means the non-generic message no longer makes the incorrect claim, while the diagnostic still explains the restriction and points to the orphan rules.

Written by the indexing model from the issue text.

Description

A-coherence A-diagnostics D-incorrect D-non-disjoint-spans D-papercut E-easy T-compiler
Code
struct Local;
impl Clone for &'static [Local] {
    fn clone(&self) -> Self {
        todo!()
    }
}
Current output
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
 --> src/main.rs:2:1
  |
2 | impl Clone for &'static [Local] {
  | ^^^^^^^^^^^^^^^----------------
  |                |
  |                this is not defined in the current crate because slices are always foreign
  |
  = note: impl doesn't have any local type before any uncovered type parameters
  = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
  = note: define and implement a trait or new type instead

(counterexample: impl From<LocalType> for i32 impls a trait defined in core for a type defined in core, but is legal)

Desired output
error[E0117]: non-generic traits defined outside the current crate can only be implemented for local types
 --> src/main.rs:2:1
  |
2 | impl Clone for &'static [Local] {
  | ^^^^^^^^^^^^^^^----------------
  |                |
  |                this is not defined in the current crate because slices are always foreign
  |
  = note: impl doesn't have any local type before any uncovered type parameters
  = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
  = note: define and implement a trait or new type instead
Rationale and extra context

Note that this message is special for non-generic traits, but makes a general statement that is incorrect for generic traits. See also #166793, which complains about the generic case not having a special message.

Other cases

The "arbitrary types" wording is odd and not used for other types, e.g.

error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
 --> src/main.rs:1:1
  |
1 | impl Copy for std::ops::Range<i32> {}

the other problem of the statement in the error being incorrect applies here as well.

Rust Version
rustc 1.102.0-nightly (c82ce1563 2026-11-27)
binary: rustc
commit-hash: c82ce15637153c025d29abbaff6035a177361788
commit-date: 2026-11-27
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.6
Anything else?

No response

Dominant language
Rust
Stars
123k
Forks
16.6k
Avg merge
2d 17h
Merged PRs (30d)
515

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rust

All issues in rust-lang/rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.