wrong suggestion when deriving clone for struct containing `dyn Fn`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず、Fn trait オブジェクトに関する E0277 の提案を扱う derive-macro の診断コードとテストを読みます。issue には最小限の再現例と誤った提案が記載されています。ここに示された struct フィールドの回帰テストを追加し、該当する診断テストを実行します。このケースで提案が表示されず、診断が引き続き Clone の実装がないことを報告すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Code
#[derive(Clone)]
struct S {
f: Box<dyn Fn()>,
}
Current output
error[E0277]: the trait bound `dyn Fn(): Clone` is not satisfied
--> src/lib.rs:3:5
|
1 | #[derive(Clone)]
| ----- in this derive macro expansion
2 | struct S {
3 | f: Box<dyn Fn()>,
| ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn Fn()`
|
= note: required for `Box<dyn Fn()>` to implement `Clone`
help: use parentheses to call this trait object
|
3 | f: Box<dyn Fn()>(),
| ++
Desired output
error[E0277]: the trait bound `dyn Fn(): Clone` is not satisfied
--> src/lib.rs:3:5
|
1 | #[derive(Clone)]
| ----- in this derive macro expansion
2 | struct S {
3 | f: Box<dyn Fn()>,
| ^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `dyn Fn()`
|
= note: required for `Box<dyn Fn()>` to implement `Clone`
Rationale and extra context
Applying the suggestion results in a syntax error:
error: expected `,`, or `}`, found `(`
--> src/lib.rs:3:21
|
2 | struct S {
| - while parsing this struct
3 | f: Box<dyn Fn()>(),
| ^
Other cases
Rust Version
rustc 1.100.0 (0ef1bc386 2026-11-09)
binary: rustc
commit-hash: 0ef1bc386059596dada8fb65b50425aab2ea637a
commit-date: 2026-11-09
host: x86_64-unknown-linux-gnu
release: 1.100.0
LLVM version: 23.1.5
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 日以内に返信
-
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 日以内に返信
-
Statement about impls in non-generic orphan rule diagnostic is incorrect and badly worded対応中かも @shamnad-sherief が 3 日前に担当しました。 オープンA-coherence A-diagnostics D-incorrect D-non-disjoint-spans D-papercut E-easy T-compiler
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
rust-lang/rust#166834 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 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 日以内に返信