Skip to content

ICE: Failed to extract DefId: opt_local_def_id_to_hir_id #114768

Closed

Description

@8051Enthusiast

Code

Can be reproduced by first building (in debug mode) crates/yaboc-hir of https://github.com/8051enthusiast/yabo at commit 442536c09df2fe898bfeda81a2788bf9dce9dc19 after a cargo clean and then building at commit 5d5d795041d55d3bcbe21c5052807711dd307f13:

git clone https://github.com/8051enthusiast/yabo
cd yabo/crates/yaboc-hir
git checkout 442536c09df2fe898bfeda81a2788bf9dce9dc19
cargo clean
cargo build
git checkout 5d5d795041d55d3bcbe21c5052807711dd307f13
cargo build # ICE

diff: 8051Enthusiast/yabo@442536c...5d5d795

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (a6f8aa5a0 2023-08-11)
binary: rustc
commit-hash: a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c
commit-date: 2023-08-11
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0

Also fails on stable.

Error output

Backtrace

thread 'rustc' panicked at compiler/rustc_middle/src/dep_graph/dep_node.rs:181:17:
Failed to extract DefId: opt_local_def_id_to_hir_id 11356bd1ee60cec5-ced77525c7774080
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/panicking.rs:67:14
   2: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
   3: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   4: <rustc_query_impl::plumbing::query_callback<rustc_query_impl::query_impl::opt_local_def_id_to_hir_id::QueryType>::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind>)>>::call_once
   5: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   6: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   7: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   8: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  11: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  12: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<rustc_middle::ty::Ty>)>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
  17: rustc_codegen_llvm::callee::get_fn
  18: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  19: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  20: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::with_task<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>::{closure#0}::{closure#0}, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  21: rustc_codegen_llvm::base::compile_codegen_unit
  22: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  24: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  25: rustc_interface::passes::start_codegen
  26: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  27: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/home/name/programs/rust/yabo/rustc-ice-2023-08-13T01:26:59.209853937Z-135604.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=/usr/bin/mold

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `core::ptr::drop_in_place::<salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>> - shim(Some(salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>))`
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 opt_def_kind(thread 'rustc' panicked at compiler/rustc_middle/src/dep_graph/dep_node.rs:181:17:
Failed to extract DefId: opt_def_kind 11356bd1ee60cec5-ced77525c7774080
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/panicking.rs:67:14
   2: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
   3: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   4: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::debug_node
   5: core::fmt::rt::Argument::fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/fmt/rt.rs:138:9
   6: core::fmt::write
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/fmt/mod.rs:1094:21
   7: std::io::Write::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/mod.rs:1714:15
   8: <&std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:945:9
   9: <std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:919:9
  10: std::io::stdio::print_to
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:1018:21
  11: std::io::stdio::_eprint
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:1106:5
  12: rustc_query_system::dep_graph::graph::print_markframe_trace::<rustc_middle::dep_graph::dep_node::DepKind>
  13: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  16: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  17: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  18: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  19: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  20: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  21: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  22: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  23: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<rustc_middle::ty::Ty>)>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
  25: rustc_codegen_llvm::callee::get_fn
  26: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  27: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  28: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::with_task<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>::{closure#0}::{closure#0}, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  29: rustc_codegen_llvm::base::compile_codegen_unit
  30: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  31: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  32: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  33: rustc_interface::passes::start_codegen
  34: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  35: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/home/name/programs/rust/yabo/rustc-ice-2023-08-13T01:26:59.209853937Z-135604.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=/usr/bin/mold

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `core::ptr::drop_in_place::<salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>> - shim(Some(salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>))`
end of query stack

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 13, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 13, 2023
  3. added
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Aug 13, 2023
  4. lukas-code commented on Aug 13, 2023

    @lukas-code
    Contributor

    Reduced:

    #![allow(dead_code)]
    
    trait Query {
        type Value;
    }
    
    struct Slot<Q>
    where
        Q: Query,
    {
        state: std::cell::Cell<QueryState<Q>>,
    }
    
    enum QueryState<Q>
    where
        Q: Query,
    {
        InProgress(Q::Value),
        Memoized(Memo<Q>),
    }
    
    struct Memo<Q>
    where
        Q: Query,
    {
        value: Q::Value,
        inputs: Box<()>,
    }
    
    struct HirNodeQuery;
    
    impl Query for HirNodeQuery {
        type Value = HirNode;
    }
    
    enum HirNode {
        A,
        #[cfg(a)]
        B(()),
    }
    
    fn conjure<T>() -> T {
        todo!()
    }
    
    fn main() {
        let _slot = conjure::<Slot<HirNodeQuery>>();
    }
    rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a
    rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b

    @rustbot label -E-needs-mcve +S-has-mcve +A-incr-comp

  5. added
    A-incr-compArea: Incremental compilation
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    and removed
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Aug 13, 2023
  6. lukas-code commented on Aug 13, 2023

    @lukas-code
    Contributor

    searched nightlies: from nightly-2023-05-13 to nightly-2023-08-13
    regressed nightly: nightly-2023-05-24
    searched commit range: 8b4b208...5ea3f0a
    regressed commit: f3d597b -> #111807

    bisected with cargo-bisect-rustc v0.6.6

    Host triple: x86_64-unknown-linux-gnu
    Reproduce with:

    cargo bisect-rustc --script script.sh -- build 

    script.sh:

    #!/bin/sh
    rm -rf incr* && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b
    
  7. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 13, 2023
  8. chenyukang commented on Aug 13, 2023

    @chenyukang
    Member

    triggered when calling is_unpin:

    Some(PointerKind::MutableRef { unpin: pointee.is_unpin(cx.tcx, cx.param_env()) })

  9. jakubadamw commented on Feb 8, 2026

    @jakubadamw
    Contributor

    This was fixed some time between rustc 1.80 (ICEs) and 1.81 (compiles fine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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