Error fix suggestion request: replace `Self` with more lifetime lenient self type name
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
The payload gives a minimal SliceMut reproducer and the current and desired lifetime may not live long enough output. Start by finding where that borrowck message is emitted and where the existing Self suggestion logic lives in rustc. Done means the note replace Self with SliceMut appears for this case, with a UI test added under tests/ui that matches the desired output.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Code
pub struct SliceMut<'a, T>(&'a mut [T]);
impl<'a, T> SliceMut<'a, T> {
pub fn subslice_ok(&mut self, start: usize, end: usize) -> SliceMut<'_, T> {
SliceMut(&mut self.0[start .. end])
}
pub fn subslice_fail(&mut self, start: usize, end: usize) -> SliceMut<'_, T> {
Self(&mut self.0[start .. end])
}
}
Current output
error: lifetime may not live long enough
--> src/lib.rs:10:14
|
4 | impl<'a, T> SliceMut<'a, T> {
| -- lifetime `'a` defined here
...
9 | pub fn subslice_fail(&mut self, start: usize, end: usize) -> SliceMut<'_, T> {
| - let's call the lifetime of this reference `'1`
10 | Self(&mut self.0[start .. end])
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this usage requires that `'1` must outlive `'a`
Desired output
error: lifetime may not live long enough
--> src/lib.rs:10:14
|
4 | impl<'a, T> SliceMut<'a, T> {
| -- lifetime `'a` defined here
...
9 | pub fn subslice_fail(&mut self, start: usize, end: usize) -> SliceMut<'_, T> {
| - let's call the lifetime of this reference `'1`
10 | Self(&mut self.0[start .. end])
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this usage requires that `'1` must outlive `'a`
note: replace `Self` with `SliceMut`
Rationale and extra context
rustc should suggest replacing concrete type Self with the not-lifetime-bound self type name when those lifetimes differ
Other cases
Rust Version
rustc 1.101.0-nightly (1a2c4797e 2026-10-21)
binary: rustc
commit-hash: 1a2c4797ef2570bd76ca5dee34449169bc7dc457
commit-date: 2026-10-21
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.4
Anything else?
No response
- Lingua principale
- Rust
- Stelle
- 123k
- Fork
- 16.6k
- Merge medio
- 2g 17h
- PR unite (30g)
- 532
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
-
C-bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
rust-lang/rust#166722 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A-run-make C-bug T-bootstrap
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Apertarelnotes relnotes-tracking-issue T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di rust-lang/rust
Issue simili
-
Thai project names become 'project', 'project-2'… (slug keeps ASCII only)Forse già presa @mastel2 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
storytold/craft-anything#2538 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
compiler-explorer/compiler-explorer#9738 ·
I maintainer di solito rispondono entro 2 giorni
-
area: runtime enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hffgzktbcc-blip/ounce-core#663 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
zellij-org/zellij#6026 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tamatebako/tebako#1155 ·
I maintainer di solito rispondono entro 1 giorno