Confusing message on inconsistent
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 122k
- Fork
- 16.7k
- Merge medio
- 2g 16h
- PR unite (30g)
- 515
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rust-lang/rust
-
Remove unnecessary parentheses when suggesting to remove '&' from a patternForse già presa @BartSimpson001 l’ha presa 1 giorno fa. ApertaA-diagnostics D-invalid-suggestion T-compiler
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`Forse già presa @ChrisDenton l’ha presa 11 giorni fa. ApertaA-filesystem C-bug O-windows T-libs
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
rust-lang/rust#165504 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
relnotes relnotes-tracking-issue T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/rust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
antithesishq/bombadil#473 ·
I maintainer di solito rispondono entro 2 giorni
-
bench/api.sh exec test fails with curl exit 52, and --ignore-failure still records the timingsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
libracoder/kiri#669 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 5 giorni
-
autofixer: follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
tursodatabase/turso#12217 ·
I maintainer di solito rispondono entro 1 giorno
-
Declare the CMS schema library in the optional recipients extraForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea:python in-progress
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
yhay81/pyropdf#1005 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno