Skip to content

ICE: expected region but found Type #138089

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
#![feature(inherent_associated_types)]
struct OnDiskDirEntry<'a> {}

impl<'a> OnDiskDirEntry<'a> {
    const LFN_FRAGMENT_LEN: i64 = 2;

    fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
        loop {}
    }
}

original:

struct OnDiskDirEntry<'a> { _s: &'a usize }

impl<'a> OnDiskDirEntry<'a> {
    const LFN_FRAGMENT_LEN: i64 = 2;

    fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] { loop { } }
    //~^ ERROR: generic `Self` types are currently not permitted in anonymous constants
}

fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
    [x; { N }]
}

Version information

rustc 1.87.0-nightly (30f168ef8 2025-03-05)
binary: rustc
commit-hash: 30f168ef811aec63124eac677e14699baa9395bd
commit-date: 2025-03-05
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs) -Zcrate-attr=feature(min_generic_const_args) -Zcrate-attr=feature(inherent_associated_types)

Program output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(generic_const_exprs)
  |         ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> 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
 --> <crate attribute>:1:9
  |
1 | feature(min_generic_const_args)
  |         ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information

warning: the feature `inherent_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(inherent_associated_types)
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information

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

error[E0392]: lifetime parameter `'a` is never used
 --> /tmp/icemaker_global_tempdir.MXAwvyNBm7fq/rustc_testrunner_tmpdir_reporting.Ap0J1t32DQwT/mvce.rs:1:23
  |
1 | struct OnDiskDirEntry<'a> {}
  |                       ^^ unused lifetime parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`


thread 'rustc' panicked at /rustc/30f168ef811aec63124eac677e14699baa9395bd/compiler/rustc_type_ir/src/binder.rs:793:9:
expected region for `'a/#0` ('a/#0/0) but found Type(OnDiskDirEntry<'a/#0>) when instantiating args=[OnDiskDirEntry<'a/#0>]
stack backtrace:
   0:     0x7798621dde24 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hf41f50ce448220db
   1:     0x779862a05aa2 - core::fmt::write::h2530ccbc5aed5a26
   2:     0x779863cd5651 - std::io::Write::write_fmt::h681bc12d66bdbd5b
   3:     0x7798621ddc82 - std::sys::backtrace::BacktraceLock::print::h1d42fe6c4d6bf7a5
   4:     0x7798621e0562 - std::panicking::default_hook::{{closure}}::h100cc14e5415da6d
   5:     0x7798621e0154 - std::panicking::default_hook::hbbe023de1b3d14d2
   6:     0x779861332fc7 - std[2ce054583824a2db]::panicking::update_hook::<alloc[52a0444d492a86c3]::boxed::Box<rustc_driver_impl[c3b441e0b8b3ec1e]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7798621e0dd3 - std::panicking::rust_panic_with_hook::hd76d2dd598e22f63
   8:     0x7798621e0aca - std::panicking::begin_panic_handler::{{closure}}::h132f3f4e3b433649
   9:     0x7798621de2e9 - std::sys::backtrace::__rust_end_short_backtrace::h6fa5bf5a960629e7
  10:     0x7798621e078d - rust_begin_unwind
  11:     0x77985ee5e920 - core::panicking::panic_fmt::h86998d6817cbe029
  12:     0x77985f179a45 - <rustc_type_ir[f1c88fa8d2ef0390]::binder::ArgFolder<rustc_middle[627fca435ebb918e]::ty::context::TyCtxt>>::region_param_expected
  13:     0x779862a3505e - <rustc_type_ir[f1c88fa8d2ef0390]::binder::ArgFolder<rustc_middle[627fca435ebb918e]::ty::context::TyCtxt> as rustc_type_ir[f1c88fa8d2ef0390]::fold::TypeFolder<rustc_middle[627fca435ebb918e]::ty::context::TyCtxt>>::fold_ty
  14:     0x779863a3735f - <rustc_middle[627fca435ebb918e]::ty::print::pretty::FmtPrinter as rustc_middle[627fca435ebb918e]::ty::print::Printer>::print_def_path
  15:     0x779863a36f16 - <rustc_middle[627fca435ebb918e]::ty::print::pretty::FmtPrinter as rustc_middle[627fca435ebb918e]::ty::print::Printer>::print_def_path
  16:     0x7798619293e3 - <rustc_middle[627fca435ebb918e]::ty::print::pretty::FmtPrinter as rustc_middle[627fca435ebb918e]::ty::print::pretty::PrettyPrinter>::pretty_print_const
  17:     0x779861959bbf - <rustc_middle[627fca435ebb918e]::ty::consts::Const as core[9e46b296f013918d]::fmt::Display>::fmt
  18:     0x779862a05aa2 - core::fmt::write::h2530ccbc5aed5a26
  19:     0x779862a0581a - alloc::fmt::format::format_inner::h4735e1d16f08de86
  20:     0x77986201160a - <rustc_trait_selection[d6d6a0fc277017bc]::error_reporting::TypeErrCtxt>::report_selection_error
  21:     0x779862066b9c - <rustc_trait_selection[d6d6a0fc277017bc]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  22:     0x77986329fd46 - rustc_hir_analysis[dbcef965d73ee94d]::check::wfcheck::check_associated_item
  23:     0x7798631999db - rustc_hir_analysis[dbcef965d73ee94d]::check::wfcheck::check_well_formed
  24:     0x779863198011 - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>
  25:     0x779863197ac8 - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_data_structures[df3cf367e6d336df]::vec_cache::VecCache<rustc_span[eec47ca1352fb626]::def_id::LocalDefId, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[db5555c7757ded81]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  26:     0x779863197583 - rustc_query_impl[e00d6234639b5a1a]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  27:     0x779863194e98 - rustc_hir_analysis[dbcef965d73ee94d]::check::wfcheck::check_mod_type_wf
  28:     0x779863194b9f - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>
  29:     0x779863999a56 - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_query_system[db5555c7757ded81]::query::caches::DefaultCache<rustc_span[eec47ca1352fb626]::def_id::LocalModDefId, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  30:     0x7798639997ff - rustc_query_impl[e00d6234639b5a1a]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  31:     0x779862da728f - rustc_hir_analysis[dbcef965d73ee94d]::check_crate
  32:     0x779862e8c2f2 - rustc_interface[f68678af3abb31c0]::passes::run_required_analyses
  33:     0x779863a0bffa - rustc_interface[f68678af3abb31c0]::passes::analysis
  34:     0x779863a0bfd9 - rustc_query_impl[e00d6234639b5a1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e00d6234639b5a1a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 0usize]>>
  35:     0x779863a5404b - rustc_query_system[db5555c7757ded81]::query::plumbing::try_execute_query::<rustc_query_impl[e00d6234639b5a1a]::DynamicConfig<rustc_query_system[db5555c7757ded81]::query::caches::SingleCache<rustc_middle[627fca435ebb918e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e00d6234639b5a1a]::plumbing::QueryCtxt, false>
  36:     0x779863a53d39 - rustc_query_impl[e00d6234639b5a1a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x779863a83e7d - rustc_interface[f68678af3abb31c0]::passes::create_and_enter_global_ctxt::<core[9e46b296f013918d]::option::Option<rustc_interface[f68678af3abb31c0]::queries::Linker>, rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  38:     0x779863abb5cf - rustc_interface[f68678af3abb31c0]::interface::run_compiler::<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}
  39:     0x77986395e648 - std[2ce054583824a2db]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f68678af3abb31c0]::util::run_in_thread_with_globals<rustc_interface[f68678af3abb31c0]::util::run_in_thread_pool_with_globals<rustc_interface[f68678af3abb31c0]::interface::run_compiler<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x77986395ef34 - <<std[2ce054583824a2db]::thread::Builder>::spawn_unchecked_<rustc_interface[f68678af3abb31c0]::util::run_in_thread_with_globals<rustc_interface[f68678af3abb31c0]::util::run_in_thread_pool_with_globals<rustc_interface[f68678af3abb31c0]::interface::run_compiler<(), rustc_driver_impl[c3b441e0b8b3ec1e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9e46b296f013918d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x779863960337 - std::sys::pal::unix::thread::Thread::new::thread_start::hed3936679d260bcc
  42:     0x77985daa370a - <unknown>
  43:     0x77985db27aac - <unknown>
  44:                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.87.0-nightly (30f168ef8 2025-03-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z crate-attr=feature(min_generic_const_args) -Z crate-attr=feature(inherent_associated_types) -Z dump-mir-dir=dir

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.MXAwvyNBm7fq/rustc_testrunner_tmpdir_reporting.Ap0J1t32DQwT/mvce.rs:3:1: 3:28>::lfn_contents` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 3 warnings emitted

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

@rustbot label +F-generic_const_exprs +F-min_generic_const_args +F-inherent_associated_types

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`F-inherent_associated_types`#![feature(inherent_associated_types)]`F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.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