Skip to content

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

Open

Description

@saethlin

I ran into this in my PR #131650 (comment) 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>

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 5, 2025
  2. added
    A-mir-optArea: MIR optimizations
    A-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)
    on Aug 5, 2025
  3. self-assigned this
    on Aug 5, 2025
  4. cjgillot commented on Aug 5, 2025

    @cjgillot
    Contributor

    I'm puzzled by this issue. SanityCheck runs just after MIR building. The only thing that happens earlier is a SimplifyCfg.

  5. saethlin commented on Aug 5, 2025

    @saethlin
    MemberAuthor

    Oh, hm. It's quite possible that in my hunt for this same error outside my PR I ran into a different problem.

  6. changed the title [-]"use of local which has no storage here" caused by GVN[/-] [+]"use of local which has no storage here" at -Zmir-opt-level=0[/+] on Aug 6, 2025
  7. saethlin commented on Aug 6, 2025

    @saethlin
    MemberAuthor

    Yeah this is definitely not the GVN issue I was hunting. It's a problem before opts.

  8. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    A-mir-optArea: MIR optimizations
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    A-mir-opt-GVNArea: MIR opt Global Value Numbering (GVN)
    on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions