Statement about impls in non-generic orphan rule diagnostic is incorrect and badly worded
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
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
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust
-
O-windows relnotes relnotes-needs-review relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Tracking issue for release notes of #161857: emit fake reads for indexing after every bounds-checkOpenrelnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang T-types
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
A-diagnostics A-dyn-trait A-macros A-suggestion-diagnostics D-invalid-suggestion T-compiler
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
rust-lang/rust#166979 · 2 comments ·
Maintainers usually reply within 1 day
-
remote-test-server truncates auxiliary dylib filenamesPossibly taken @shuvakant6623 claimed this 2 days ago. OpenA-cross A-test-infra A-testsuite C-bug T-bootstrap
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-lang/rust#166910 · 4 comments ·
Maintainers usually reply within 1 day
-
O-musl relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
Similar issues
-
marketing
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothOpenarea/ode-pde good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#383 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Maintainers usually reply within 1 day
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
nledford/Ladderback#2028 ·
Maintainers usually reply within 1 day