`unused_variables` warns on a binding used only as `..base` when every field is given, and the `_` prefix it suggests leaves `..base` unresolved (E0425)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
Línea de trabajo
The report points to the unused_variables lint moving to MIR in #142390 and includes a repro.sh script that runs cargo check and cargo fix on a copy of the example crate. Start by running the reproduction and tracing how struct update bases are counted as uses and how the lint suggestion renames bindings. Done means cargo fix no longer produces E0425 for this case, with the partial struct update behavior preserved.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Code
I tried this code (lib.rs of a library crate, edition 2024):
#[derive(Clone, Copy)]
pub struct Margins {
pub top: i32,
pub left: i32,
}
pub fn changed(margins: Margins, change: impl Fn(Margins) -> Margins) -> Margins {
change(margins)
}
pub fn reset(margins: Margins) -> Margins {
changed(margins, |group| Margins { top: 0, left: 0, ..group })
}
The crate and repro.sh, a script that runs cargo check and then cargo fix --allow-no-vcs on a copy of it, are in a gist: https://gist.github.com/YevheniiKotyrlo/a435bd0806dbf257f4a8375608bf3895
git clone https://gist.github.com/a435bd0806dbf257f4a8375608bf3895.git struct-update-base
cd struct-update-base
bash repro.sh
bash repro.sh exits 1 while cargo fix fails with E0425, 0 once rustc no longer warns or the fix leaves a crate that builds, and 2 otherwise.
I expected to see this happen: no unused_variables warning on group, since ..group names it; or, if the warning stays, a suggestion whose result compiles, renaming the ..group use too or removing the base.
Instead, this happened: cargo check warns
warning: unused variable: `group`
--> lib.rs:12:23
|
12 | changed(margins, |group| Margins { top: 0, left: 0, ..group })
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_group`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
and cargo fix --allow-no-vcs applies the suggestion, gets E0425 and backs it out:
error: errors present after applying fixes to crate `struct_update_base_probe`
--> lib.rs
= cause: error[E0425]: cannot find value `group` in this scope
--> lib.rs:12:60
|
12 | changed(margins, |_group| Margins { top: 0, left: 0, ..group })
| ^^^^^ not found in this scope
[…]
error: aborting due to 1 previous error
A function parameter and a let binding used only as such a base get the same warning and suggestion; a base that still gives a field gets none:
pub fn parameter(group: Margins) -> Margins {
Margins { top: 0, left: 0, ..group } // warns at `group: Margins`
}
pub fn local(margins: Margins) -> Margins {
let group = margins;
Margins { top: 0, left: 0, ..group } // warns at `let group`
}
pub fn partial(margins: Margins) -> Margins {
let group = margins;
Margins { top: 0, ..group } // no warning
}
Version it worked on
It most recently worked on: Rust 1.91.0 (rustc 1.91.0 (f8297e351 2025-10-28)), where cargo check gives no warning. 1.92.0 is the first release with it, which fits unused_variables moving to MIR in #142390.
Version with regression
rustc --version --verbose:
rustc 1.100.0 (0ef1bc386 2026-11-09)
binary: rustc
commit-hash: 0ef1bc386059596dada8fb65b50425aab2ea637a
commit-date: 2026-11-09
host: x86_64-pc-windows-msvc
release: 1.100.0
LLVM version: 23.1.5
1.92.0 (rustc 1.92.0 (ded5c06cf 2025-12-08)) and nightly-2026-11-28 (rustc 1.102.0-nightly (c82ce1563 2026-11-27)) give the same warning and the same E0425.
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
- Lenguaje dominante
- Rust
- Estrellas
- 123k
- Forks
- 16.6k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 532
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rust
-
strictly_dominates missing a `=`AbiertoC-bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rust-lang/rust#166722 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
A-attributes relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-lang
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-run-make C-bug T-bootstrap
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Tracking issue for release notes of #161531: Remove `T: Send + Sync` bound from `Arc::downcast`Abiertorelnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
A-str A-Unicode relnotes relnotes-tracking-issue T-libs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/rust
Issues similares
-
bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug core-lang
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Windows microphone listing treats words in a device name as DirectShow labelsPosiblemente ocupada @Sujal-chaudhary la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
clipy-recorder/clipy#447 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
nightly-cleanup
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
max-sixty/worktrunk#4939 · 1 reacción ·
Los mantenedores suelen responder en 1 día