rust-lang / rust-lang/rust

[ICE]: expected region for .. but found Type ..

Open
#155,892 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-inherent_associated_types F-min_generic_const_args I-ICE needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(inherent_associated_types)]
#![feature(min_generic_const_args)]
struct OnDiskDirEntry<'a> {
    ,
}
impl<'a> OnDiskDirEntry<'a> {
    type const LFN_FRAGMENT_LEN: usize = 3;
    fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
        2
    }
}



original:

#![feature(inherent_associated_types)]
#![feature(min_generic_const_args)]
struct OnDiskDirEntry<'a> {
    a: &'a str,
}
impl<'a> OnDiskDirEntry<'a> {
    type const LFN_FRAGMENT_LEN: usize = 3;
    fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
        2
    }
}

fn main() {}

Version information

rustc 1.97.0-nightly (345a975e7 2026-04-27)
binary: rustc
commit-hash: 345a975e76de74f090c55d5b56f5f6dd41b655a2
commit-date: 2026-04-27
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2

Possibly related line of code:
https://github.com/rust-lang/rust/blob/345a975e76de74f090c55d5b56f5f6dd41b655a2/compiler/rustc_type_ir/src/binder.rs#L846-L858

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

error: expected identifier, found `,`
 --> /tmp/icemaker_global_tempdir.1DKMRuVQsV2v/rustc_testrunner_tmpdir_reporting.8PmYhQSsMCBd/mvce.rs:4:5
  |
3 | struct OnDiskDirEntry<'a> {
  |        -------------- while parsing this struct
4 |     ,
  |     ^ expected identifier

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

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.1DKMRuVQsV2v/rustc_testrunner_tmpdir_reporting.8PmYhQSsMCBd/mvce.rs:2:12
  |
2 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.1DKMRuVQsV2v/rustc_testrunner_tmpdir_reporting.8PmYhQSsMCBd/mvce.rs:11:2
   |
11 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.1DKMRuVQsV2v/rustc_testrunner_tmpdir_reporting.8PmYhQSsMCBd/mvce.rs`


thread 'rustc' (1111333) panicked at /rustc-dev/345a975e76de74f090c55d5b56f5f6dd41b655a2/compiler/rustc_type_ir/src/binder.rs:852:9:
expected region for `'a/#0` ('a/#0/0) but found Type(OnDiskDirEntry<'a/#0>) when instantiating args=[OnDiskDirEntry<'a/#0>]
stack backtrace:
   0:     0x7f3cf5cfae99 - <<std[a9eb3f39b69ad3ff]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b04a2f1476229c25]::fmt::Display>::fmt
   1:     0x7f3cf6415e48 - core[b04a2f1476229c25]::fmt::write
   2:     0x7f3cf5d11986 - <std[a9eb3f39b69ad3ff]::sys::stdio::unix::Stderr as std[a9eb3f39b69ad3ff]::io::Write>::write_fmt
   3:     0x7f3cf5cd109e - std[a9eb3f39b69ad3ff]::panicking::default_hook::{closure#0}
   4:     0x7f3cf5cee583 - std[a9eb3f39b69ad3ff]::panicking::default_hook
   5:     0x7f3cf4cd9a71 - std[a9eb3f39b69ad3ff]::panicking::update_hook::<alloc[f5407cb677668734]::boxed::Box<rustc_driver_impl[4eedd31b7089c8cf]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f3cf5cee862 - std[a9eb3f39b69ad3ff]::panicking::panic_with_hook
   7:     0x7f3cf5cd1162 - std[a9eb3f39b69ad3ff]::panicking::panic_handler::{closure#0}
   8:     0x7f3cf5cc5659 - std[a9eb3f39b69ad3ff]::sys::backtrace::__rust_end_short_backtrace::<std[a9eb3f39b69ad3ff]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f3cf5cd2bcd - __rustc[929c9a63fff72118]::rust_begin_unwind
  10:     0x7f3cf29183cc - core[b04a2f1476229c25]::panicking::panic_fmt
  11:     0x7f3cf2958271 - <rustc_type_ir[aefac294ccc7744]::binder::ArgFolder<rustc_middle[dbb0bf4bafb0ab2f]::ty::context::TyCtxt>>::region_param_expected
  12:     0x7f3cf6443e29 - <rustc_type_ir[aefac294ccc7744]::binder::ArgFolder<rustc_middle[dbb0bf4bafb0ab2f]::ty::context::TyCtxt> as rustc_type_ir[aefac294ccc7744]::fold::TypeFolder<rustc_middle[dbb0bf4bafb0ab2f]::ty::context::TyCtxt>>::fold_ty
  13:     0x7f3cf52d97cf - <rustc_type_ir[aefac294ccc7744]::binder::EarlyBinder<rustc_middle[dbb0bf4bafb0ab2f]::ty::context::TyCtxt, rustc_middle[dbb0bf4bafb0ab2f]::ty::Ty>>::instantiate::<&[rustc_middle[dbb0bf4bafb0ab2f]::ty::generic_args::GenericArg]>
  14:     0x7f3cf7792d98 - <rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::FmtPrinter as rustc_middle[dbb0bf4bafb0ab2f]::ty::print::Printer>::print_def_path
  15:     0x7f3cf7792974 - <rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::FmtPrinter as rustc_middle[dbb0bf4bafb0ab2f]::ty::print::Printer>::print_def_path
  16:     0x7f3cf538c851 - <rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::FmtPrinter as rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::PrettyPrinter>::pretty_print_const
  17:     0x7f3cf7794774 - <rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::FmtPrinter as rustc_middle[dbb0bf4bafb0ab2f]::ty::print::pretty::PrettyPrinter>::pretty_print_type
  18:     0x7f3cf533706f - <rustc_middle[dbb0bf4bafb0ab2f]::ty::Ty as rustc_error_messages[caeaf8dd9fec5fd]::IntoDiagArg>::into_diag_arg
  19:     0x7f3cf4f6ce8f - <rustc_hir_typeck[4f770d89427b513d]::errors::ExpectedReturnTypeLabel as rustc_errors[5d147c2ea826cfcc]::diagnostic::Subdiagnostic>::add_to_diag::<rustc_span[bbe1d656f07b00ee]::ErrorGuaranteed>
  20:     0x7f3cf4fc9e8e - <rustc_hir_typeck[4f770d89427b513d]::fn_ctxt::FnCtxt>::suggest_missing_return_type
  21:     0x7f3cf4fcca5e - <rustc_hir_typeck[4f770d89427b513d]::fn_ctxt::FnCtxt>::suggest_mismatched_types_on_tail
  22:     0x7f3cf447ff6c - <rustc_hir_typeck[4f770d89427b513d]::coercion::CoerceMany>::report_return_mismatched_types
  23:     0x7f3cf68a83fa - <rustc_hir_typeck[4f770d89427b513d]::fn_ctxt::FnCtxt>::check_expr_block
  24:     0x7f3cf689086f - <rustc_hir_typeck[4f770d89427b513d]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f3cf689bf05 - rustc_hir_typeck[4f770d89427b513d]::check::check_fn
  26:     0x7f3cf6d9a506 - rustc_hir_typeck[4f770d89427b513d]::typeck_with_inspect::{closure#0}
  27:     0x7f3cf6d97404 - rustc_query_impl[2be19ef8da6108aa]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  28:     0x7f3cf6518166 - rustc_query_impl[2be19ef8da6108aa]::execution::try_execute_query::<rustc_data_structures[fb6e4346a2abdb30]::vec_cache::VecCache<rustc_span[bbe1d656f07b00ee]::def_id::LocalDefId, rustc_middle[dbb0bf4bafb0ab2f]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[dbb0bf4bafb0ab2f]::dep_graph::graph::DepNodeIndex>, false>
  29:     0x7f3cf6517a43 - rustc_query_impl[2be19ef8da6108aa]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7f3cf6ca8a54 - <rustc_middle[dbb0bf4bafb0ab2f]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[54c6f91f6d421f22]::check_crate::{closure#1}>::{closure#0}
  31:     0x7f3cf6ca8426 - rustc_hir_analysis[54c6f91f6d421f22]::check_crate
  32:     0x7f3cf7343821 - rustc_interface[fb0ae15303da83fc]::passes::analysis
  33:     0x7f3cf757e7c9 - rustc_query_impl[2be19ef8da6108aa]::execution::try_execute_query::<rustc_middle[dbb0bf4bafb0ab2f]::query::caches::SingleCache<rustc_middle[dbb0bf4bafb0ab2f]::query::erase::ErasedData<[u8; 0usize]>>, false>
  34:     0x7f3cf757e429 - rustc_query_impl[2be19ef8da6108aa]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  35:     0x7f3cf759b742 - rustc_interface[fb0ae15303da83fc]::interface::run_compiler::<(), rustc_driver_impl[4eedd31b7089c8cf]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7f3cf75731fe - std[a9eb3f39b69ad3ff]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[fb0ae15303da83fc]::util::run_in_thread_with_globals<rustc_interface[fb0ae15303da83fc]::util::run_in_thread_pool_with_globals<rustc_interface[fb0ae15303da83fc]::interface::run_compiler<(), rustc_driver_impl[4eedd31b7089c8cf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7f3cf75738ed - <std[a9eb3f39b69ad3ff]::thread::lifecycle::spawn_unchecked<rustc_interface[fb0ae15303da83fc]::util::run_in_thread_with_globals<rustc_interface[fb0ae15303da83fc]::util::run_in_thread_pool_with_globals<rustc_interface[fb0ae15303da83fc]::interface::run_compiler<(), rustc_driver_impl[4eedd31b7089c8cf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b04a2f1476229c25]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f3cf757472c - <std[a9eb3f39b69ad3ff]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7f3cf10a597a - <unknown>
  40:     0x7f3cf11292bc - <unknown>
  41:                0x0 - <unknown>

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

note: rustc 1.97.0-nightly (345a975e7 2026-04-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck_root] type-checking `<impl at /tmp/icemaker_global_tempdir.1DKMRuVQsV2v/rustc_testrunner_tmpdir_reporting.8PmYhQSsMCBd/mvce.rs:6:1: 6:28>::lfn_contents`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors; 2 warnings emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-inherent_associated_types +F-min_generic_const_args +WG-trait-system-refactor

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

Reproduce the ICE with the reduced a.rs example and -Znext-solver=globally, then inspect compiler/rustc_type_ir/src/binder.rs around region_param_expected at lines 846-858. Determine why the reported generic arguments reach this path with a type where a region is expected, and add a regression test showing compilation no longer panics.

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
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.