rust-lang / rust-lang/rust

"use of local which has no storage here" at -Zmir-opt-level=0

Open
#144,932 3 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.