Confusing message on inconsistent
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by tracing how the mismatched_lifetime_syntaxes lint builds its spans and help text for elided input lifetimes and hidden output lifetimes. Reproduce the example with the stated Rust version, then inspect existing lint tests for similar cases. Done means the diagnostic explains this case accurately, with tests covering the chosen wording or behavior.
索引モデルが issue の本文から書いたものです。
説明
Code
#![allow(dead_code)]
struct HintRef<'a>(&'a u8);
fn hint(value: &u8) -> HintRef {
HintRef(value)
}
fn main() {}
Current output
warning: hiding a lifetime that's elided elsewhere is confusing
--> src/main.rs:5:16
|
5 | fn hint(value: &u8) -> HintRef {
| ^^^ ^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
|
5 | fn hint(value: &u8) -> HintRef<'_> {
| ++++
Rationale and extra context
"the same lifetime is referred to in inconsistent ways" doesn't make sense in this context: neither the & nor the HintRef have any lifetime written, so arguably they are consistent?
I'm not sure what the cleanest option is here:
(1) Explicit mention of sugar:
5 | fn hint(value: &u8) -> HintRef {
| ^^^ ^^^^^^^ the same lifetime is hidden here
| |
| this lifetime is `_
(2) Just drop the warning in this case?
I'd also be tempted to change the span to only apply to the &, something like this:
5 | fn hint(value: &u8) -> HintRef {
| ^ ^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
Rust Version
rustc 1.100.0 on the playground reproduces this.
- 主要言語
- Rust
- スター
- 122k
- フォーク
- 16.7k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 515
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust のほかの issue
-
Remove unnecessary parentheses when suggesting to remove '&' from a pattern対応中かも @BartSimpson001 が 1 日前に担当しました。 オープンA-diagnostics D-invalid-suggestion T-compiler
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`対応中かも @ChrisDenton が 11 日前に担当しました。 オープンA-filesystem C-bug O-windows T-libs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
rust-lang/rust#165504 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
relnotes relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
antithesishq/bombadil#473 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
libracoder/kiri#669 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 5 日以内に返信
-
autofixer: follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
tursodatabase/turso#12217 ·
メンテナーはふだん 1 日以内に返信
-
Declare the CMS schema library in the optional recipients extra対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea:python in-progress
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
yhay81/pyropdf#1005 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信