rust-lang / rust-lang/rust

ICE `invalid Res .. for const path`

Open
#150,749 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-min_generic_const_args I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

snippet:

#![feature(min_generic_const_args)]

trait CollectArray {
    fn inner_array();
}
impl CollectArray for () {
    fn inner_array() {
        let temp_ptr: [(); Self];
    }
}
fn main() {}

Version information

rustc 1.94.0-nightly (4d73a008e 2026-01-06)
binary: rustc
commit-hash: 4d73a008eaf6ba3ca067a3221e5c00602e33a5f2
commit-date: 2026-01-06
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8

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

Program output

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.vyLbJJh66pGl/rustc_testrunner_tmpdir_reporting.bljQfewf7ESR/mvce.rs:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: trait `CollectArray` is never used
 --> /tmp/icemaker_global_tempdir.vyLbJJh66pGl/rustc_testrunner_tmpdir_reporting.bljQfewf7ESR/mvce.rs:3:7
  |
3 | trait CollectArray<A> {
  |       ^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: 2 warnings emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: invalid Res SelfCtor(DefId(0:6 ~ mvce[7e87]::{impl#0})) for const path
 --> /tmp/icemaker_global_tempdir.vyLbJJh66pGl/rustc_testrunner_tmpdir_reporting.bljQfewf7ESR/mvce.rs:8:27
  |
8 |         let temp_ptr: [A; Self];
  |                           ^^^^
  |
note: delayed at /rustc-dev/4d73a008eaf6ba3ca067a3221e5c00602e33a5f2/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2687:28
         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: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_resolved_const_path.cold
         5: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_const_arg
         6: <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_ty
         7: <rustc_hir_typeck::gather_locals::GatherLocalsVisitor>::declare
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: rustc_hir_typeck::check::check_fn
        11: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        14: rustc_query_impl::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
        15: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
        16: rustc_hir_analysis::check_crate
        17: rustc_interface::passes::analysis
        18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        20: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
        21: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
        22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        23: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        24: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        25: <std::sys::thread::unix::Thread>::new::thread_start
        26: <unknown>
        27: <unknown>
      
 --> /tmp/icemaker_global_tempdir.vyLbJJh66pGl/rustc_testrunner_tmpdir_reporting.bljQfewf7ESR/mvce.rs:8:27
  |
8 |         let temp_ptr: [A; Self];
  |                           ^^^^

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.94.0-nightly (4d73a008e 2026-01-06) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +F-min_generic_const_args

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.

Research direction

Compile the supplied snippet with the nightly toolchain and the min_generic_const_args feature to reproduce the ICE. Then inspect compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs, especially lower_resolved_const_path and the lower_const_arg call path at the reported location. Done means the snippet no longer produces an internal compiler error and the regression is covered by a compiler test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.