Skip to content

ICE No HirId for DefId #149695

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Trait<T: ?Sized> {
    
}

fn produce() -> impl for<A: A< {
    
    

    
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    enum A { A, A{ C  C: } }

    

    struct A<A> {
        A: A,
    }

    
    

    
    
} >> Trait<(), > {
    16
}

original:

#![feature(non_lifetime_binders)]

trait Trait<T: ?Sized> {
    type Assoc;
}

fn produce() -> impl for<A: A< {
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    enum A { A(A), }

    #[repr(i16)]
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    enum A { A, A{ C  C: } }

    #[ignore  = "msg"]
#[should_panic]
    struct A<A> {
        A: A,
    }

    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    struct A<A: A>(B)
    where
        A: A< continue >;

    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    enum A<A> {
        A(
),
        A { A: A },
    }
} >> Trait<(), Assoc = impl Trait<T>> {
    16
}

Version information

rustc 1.93.0-nightly (66428d92b 2025-12-05)
binary: rustc
commit-hash: 66428d92bec337ed4785d695d0127276a482278c
commit-date: 2025-12-05
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: expected `:`, found `C`
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:13:23
   |
13 |     enum A { A, A{ C  C: } }
   |                 -     ^ expected `:`
   |                 |
   |                 while parsing this struct

error[E0428]: the name `A` is defined multiple times
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:17:5
   |
13 |     enum A { A, A{ C  C: } }
   |     ------ previous definition of the type `A` here
...
17 |     struct A<A> {
   |     ^^^^^^^^^^^ `A` redefined here
   |
   = note: `A` must be defined only once in the type namespace of this block

error[E0428]: the name `A` is defined multiple times
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:13:17
   |
13 |     enum A { A, A{ C  C: } }
   |              -  ^ `A` redefined here
   |              |
   |              previous definition of the type `A` here
   |
   = note: `A` must be defined only once in the type namespace of this enum

error[E0658]: only lifetime parameters can be used in this context
 --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:7:26
  |
7 | fn produce() -> impl for<A: A< {
  |                          ^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
  = note: this compiler was built on 2025-12-05; consider upgrading it if it is out of date

error: bounds cannot be used in this context
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:7:29
   |
 7 |   fn produce() -> impl for<A: A< {
   |  _____________________________^
...  |
26 | | } >> Trait<(), > {
   | |___^

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:28:2
   |
28 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs`

error[E0277]: the trait bound `{integer}: Trait<()>` is not satisfied
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:7:17
   |
 7 |   fn produce() -> impl for<A: A< {
   |  _________________^
...  |
26 | | } >> Trait<(), > {
   | |________________^ the trait `Trait<()>` is not implemented for `{integer}`
27 |       16
   |       -- return type was inferred to be `{integer}` here
   |
help: this trait has no implementations, consider adding one
  --> /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:3:1
   |
 3 | trait Trait<T: ?Sized> {
   | ^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: /rustc-dev/66428d92bec337ed4785d695d0127276a482278c/compiler/rustc_middle/src/hir/mod.rs:377:32: No HirId for DefId(0:8 ~ mvce[f267]::produce::{opaque#0}::{constant#0})


thread 'rustc' (2704135) panicked at /rustc-dev/66428d92bec337ed4785d695d0127276a482278c/compiler/rustc_middle/src/hir/mod.rs:377:32:
Box<dyn Any>
stack backtrace:
   0:     0x7f0873e6f6b3 - <<std[d1cf8494b7637499]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7a5baad27c58ac9b]::fmt::Display>::fmt
   1:     0x7f0874411848 - core[7a5baad27c58ac9b]::fmt::write
   2:     0x7f0873e85ed6 - <std[d1cf8494b7637499]::sys::stdio::unix::Stderr as std[d1cf8494b7637499]::io::Write>::write_fmt
   3:     0x7f0873e45e78 - std[d1cf8494b7637499]::panicking::default_hook::{closure#0}
   4:     0x7f0873e63583 - std[d1cf8494b7637499]::panicking::default_hook
   5:     0x7f0872ecfec7 - std[d1cf8494b7637499]::panicking::update_hook::<alloc[fc8570482610e41]::boxed::Box<rustc_driver_impl[9b4b378bd639d3bd]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0873e63862 - std[d1cf8494b7637499]::panicking::panic_with_hook
   7:     0x7f0872f0bf41 - std[d1cf8494b7637499]::panicking::begin_panic::<rustc_errors[888950e5e47c8ba6]::ExplicitBug>::{closure#0}
   8:     0x7f0872efc596 - std[d1cf8494b7637499]::sys::backtrace::__rust_end_short_backtrace::<std[d1cf8494b7637499]::panicking::begin_panic<rustc_errors[888950e5e47c8ba6]::ExplicitBug>::{closure#0}, !>
   9:     0x7f0872efc1cf - std[d1cf8494b7637499]::panicking::begin_panic::<rustc_errors[888950e5e47c8ba6]::ExplicitBug>
  10:     0x7f0872f29641 - <rustc_errors[888950e5e47c8ba6]::diagnostic::BugAbort as rustc_errors[888950e5e47c8ba6]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f087348b959 - rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt::<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}
  12:     0x7f087348bae2 - rustc_middle[35056dba64335523]::ty::context::tls::with_opt::<rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f087347cdbb - rustc_middle[35056dba64335523]::ty::context::tls::with_context_opt::<rustc_middle[35056dba64335523]::ty::context::tls::with_opt<rustc_middle[35056dba64335523]::util::bug::opt_span_bug_fmt<rustc_span[a0d314e698c4c838]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f08718db7c4 - rustc_middle[35056dba64335523]::util::bug::bug_fmt
  15:     0x7f087469e207 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::local_def_id_to_hir_id::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>
  16:     0x7f087469d5f7 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_data_structures[adb2697dbf3e0adc]::vec_cache::VecCache<rustc_span[a0d314e698c4c838]::def_id::LocalDefId, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[59d0c891baa5ac40]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  17:     0x7f087469d34b - rustc_query_impl[ac86e4dc6825f939]::query_impl::local_def_id_to_hir_id::get_query_non_incr::__rust_end_short_backtrace
  18:     0x7f0874a4397f - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::hir_owner_parent::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>
  19:     0x7f0874a429b7 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_data_structures[adb2697dbf3e0adc]::vec_cache::VecCache<rustc_hir_id[3f20a8067ac1f93b]::OwnerId, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[59d0c891baa5ac40]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  20:     0x7f0874a4258b - rustc_query_impl[ac86e4dc6825f939]::query_impl::hir_owner_parent::get_query_non_incr::__rust_end_short_backtrace
  21:     0x7f0874bd40e5 - <rustc_middle[35056dba64335523]::hir::map::ParentHirIterator as core[7a5baad27c58ac9b]::iter::traits::iterator::Iterator>::next
  22:     0x7f087305b8cd - <rustc_hir_analysis[c90d90e42cbb1186]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::get_type_or_const_args_suggestions_from_param_names
  23:     0x7f0872fccadf - <rustc_hir_analysis[c90d90e42cbb1186]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::suggest_adding_args::<rustc_span[a0d314e698c4c838]::ErrorGuaranteed>
  24:     0x7f08730d2820 - <rustc_hir_analysis[c90d90e42cbb1186]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs as rustc_errors[888950e5e47c8ba6]::diagnostic::Diagnostic>::into_diag
  25:     0x7f0874bb1e9a - <dyn rustc_hir_analysis[c90d90e42cbb1186]::hir_ty_lowering::HirTyLowerer>::lower_resolved_ty_path
  26:     0x7f0874ba7d9b - <dyn rustc_hir_analysis[c90d90e42cbb1186]::hir_ty_lowering::HirTyLowerer>::lower_ty::{closure#0}
  27:     0x7f0874bcb065 - rustc_hir_analysis[c90d90e42cbb1186]::collect::type_of::type_of
  28:     0x7f087441b6e8 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7f087441a3c6 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  30:     0x7f0874419f6f - rustc_query_impl[ac86e4dc6825f939]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7f08745431e8 - rustc_middle[35056dba64335523]::ty::trait_def::trait_impls_of_provider
  32:     0x7f0874542563 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::trait_impls_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>
  33:     0x7f087441a3c6 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  34:     0x7f08744638a5 - rustc_query_impl[ac86e4dc6825f939]::query_impl::trait_impls_of::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7f087446376e - <rustc_middle[35056dba64335523]::ty::context::TyCtxt>::all_impls
  36:     0x7f087446393d - rustc_trait_selection[bfbaae654e06ec63]::traits::specialize::specialization_graph_provider
  37:     0x7f08744638cd - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>
  38:     0x7f087441a3c6 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  39:     0x7f087454f75b - rustc_query_impl[ac86e4dc6825f939]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f0874552977 - rustc_hir_analysis[c90d90e42cbb1186]::coherence::coherent_trait
  41:     0x7f0874552695 - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>
  42:     0x7f0874977be3 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  43:     0x7f0874976ca4 - rustc_query_impl[ac86e4dc6825f939]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  44:     0x7f0874d4279c - rustc_middle[35056dba64335523]::query::inner::query_ensure_error_guaranteed::<rustc_query_system[59d0c891baa5ac40]::query::caches::DefIdCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 1usize]>>, ()>
  45:     0x7f0874feb548 - rustc_hir_analysis[c90d90e42cbb1186]::check_crate
  46:     0x7f0874696e95 - rustc_interface[a570f551ea6bf79f]::passes::analysis
  47:     0x7f0874696b5b - rustc_query_impl[ac86e4dc6825f939]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ac86e4dc6825f939]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 0usize]>>
  48:     0x7f0875564388 - rustc_query_system[59d0c891baa5ac40]::query::plumbing::try_execute_query::<rustc_query_impl[ac86e4dc6825f939]::DynamicConfig<rustc_query_system[59d0c891baa5ac40]::query::caches::SingleCache<rustc_middle[35056dba64335523]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ac86e4dc6825f939]::plumbing::QueryCtxt, false>
  49:     0x7f0875563fbe - rustc_query_impl[ac86e4dc6825f939]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  50:     0x7f08756f6410 - <rustc_interface[a570f551ea6bf79f]::passes::create_and_enter_global_ctxt<core[7a5baad27c58ac9b]::option::Option<rustc_interface[a570f551ea6bf79f]::queries::Linker>, rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7a5baad27c58ac9b]::ops::function::FnOnce<(&rustc_session[61d9c53fe18acc9a]::session::Session, rustc_middle[35056dba64335523]::ty::context::CurrentGcx, alloc[fc8570482610e41]::sync::Arc<rustc_data_structures[adb2697dbf3e0adc]::jobserver::Proxy>, &std[d1cf8494b7637499]::sync::once_lock::OnceLock<rustc_middle[35056dba64335523]::ty::context::GlobalCtxt>, &rustc_data_structures[adb2697dbf3e0adc]::sync::worker_local::WorkerLocal<rustc_middle[35056dba64335523]::arena::Arena>, &rustc_data_structures[adb2697dbf3e0adc]::sync::worker_local::WorkerLocal<rustc_hir[670b2116001876c4]::Arena>, rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  51:     0x7f08755b8c85 - rustc_interface[a570f551ea6bf79f]::interface::run_compiler::<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}
  52:     0x7f087550e1d6 - std[d1cf8494b7637499]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_with_globals<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_pool_with_globals<rustc_interface[a570f551ea6bf79f]::interface::run_compiler<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  53:     0x7f087550dfa9 - <std[d1cf8494b7637499]::thread::lifecycle::spawn_unchecked<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_with_globals<rustc_interface[a570f551ea6bf79f]::util::run_in_thread_pool_with_globals<rustc_interface[a570f551ea6bf79f]::interface::run_compiler<(), rustc_driver_impl[9b4b378bd639d3bd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7a5baad27c58ac9b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7f087550c3f8 - <std[d1cf8494b7637499]::sys::thread::unix::Thread>::new::thread_start
  55:     0x7f086f0969cb - <unknown>
  56:     0x7f086f11aa0c - <unknown>
  57:                0x0 - <unknown>

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 make sure that you have updated to the latest nightly

note: rustc 1.93.0-nightly (66428d92b 2025-12-05) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `produce::{opaque#0}::{constant#0}`
#1 [hir_owner_parent] getting HIR parent of `produce::{opaque#0}::{constant#0}::<impl at /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:12:14: 12:18>`
#2 [type_of] computing type of `produce::{opaque#0}::{constant#0}::<impl at /tmp/icemaker_global_tempdir.nyMyaiftF75w/rustc_testrunner_tmpdir_reporting.re9MAsDkvErY/mvce.rs:12:14: 12:18>`
#3 [trait_impls_of] finding trait impls of `core::marker::Copy`
#4 [specialization_graph_of] building specialization graph of trait `core::marker::Copy`
#5 [coherent_trait] coherence checking all impls of trait `core::marker::Copy`
#6 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 8 previous errors

Some errors have detailed explanations: E0277, E0428, E0601, E0658.
For more information about an error, try `rustc --explain E0277`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`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