Statement about impls in non-generic orphan rule diagnostic is incorrect and badly worded
メンテナーはふだん 1 日以内に返信
@shamnad-sherief がすでに取り組んでいます。
2026年12月2日 から。
評価
調査の方向性
issueに示されているE0117の文言をrustcの診断から探し、ジェネリックでないトレイト向けの診断を選択するコードを読んでください。その文言を、ジェネリックな孤児ルールの診断およびissueの例と比較してください。ジェネリックでないトレイト向けのメッセージが誤った主張をしなくなり、制約の説明と孤児ルールへの参照が引き続き含まれていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Rust
- スター
- 123k
- フォーク
- 16.6k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 515
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust のほかの issue
-
O-windows relnotes relnotes-needs-review relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Tracking issue for release notes of #161857: emit fake reads for indexing after every bounds-checkオープンrelnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang T-types
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
A-diagnostics A-dyn-trait A-macros A-suggestion-diagnostics D-invalid-suggestion T-compiler
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
rust-lang/rust#166979 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
remote-test-server truncates auxiliary dylib filenames対応中かも @shuvakant6623 が 2 日前に担当しました。 オープンA-cross A-test-infra A-testsuite C-bug T-bootstrap
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
rust-lang/rust#166910 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
O-musl relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
marketing
難易度 1/5 1〜3時間 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothオープンarea/ode-pde good first issue help wanted kind/contract severity/4-minor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Apich-Organization/rssn#383 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
nledford/Ladderback#2028 ·
メンテナーはふだん 1 日以内に返信