"use of local which has no storage here" at -Zmir-opt-level=0
Open
@cjgillot is already working on this.
Since Aug 5, 2025.
A-MIR
C-bug
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I ran into this in my PR https://github.com/rust-lang/rust/pull/131650#issuecomment-3148697757 when trying to use GVN more, because MIR "lints" are enabled in the mir-opt suite.
This lint fires a fair bit in the ecosystem, for example in zvariant-5.6.0, compiling with RUSTFLAGS="-Zlint-mir -Zmir-opt-level=0 -Zmir-enable-passes=+GVN" cargo +nightly build
error: internal compiler error: broken MIR in Item(DefId(0:1107 ~ zvariant[4905]::dbus::ser::{impl#4}::serialize_struct_element)) (after pass SanityCheck) at bb46[0]:
use of local _10, which has no storage here
--> src/dbus/ser.rs:540:5
|
540 | }
| ^
|
note: delayed at compiler/rustc_mir_transform/src/lint.rs:74:22
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
4: <rustc_mir_transform::lint::Lint>::fail::<alloc::string::String>
5: <rustc_mir_transform::lint::Lint as rustc_middle::mir::visit::Visitor>::visit_local
6: <rustc_mir_transform::lint::Lint as rustc_middle::mir::visit::Visitor>::visit_place
7: <rustc_mir_transform::lint::Lint as rustc_middle::mir::visit::Visitor>::visit_terminator
8: rustc_mir_transform::lint::lint_body
9: rustc_mir_transform::mir_built
<snip>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.