Skip to content

ICE: unreachable #139633

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    let str::<
        {
            fn str(_: u8, ...) {}
        },
        T,
    >::as_bytes;
}

original:

fn main() {
    let str::<{fn str(_: u8, ...) { let str::T>>::as_bytes; }}, T>::as_bytes;
//~^ ERROR expected a pattern, found an expression
//~| ERROR cannot find type `T` in this scope
//~| ERROR const and type arguments are not allowed on builtin type `str`
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<
//~| ERROR type annotations needed
}

Version information

rustc 1.88.0-nightly (7d7de5bf3 2025-04-10)
binary: rustc
commit-hash: 7d7de5bf3c3cbf9c2c5bbc5cbfb9197a8a427d35
commit-date: 2025-04-10
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

fn print_pat(&mut self, pat: &hir::Pat<'_>) {
self.maybe_print_comment(pat.span.lo());
self.ann.pre(self, AnnNode::Pat(pat));
// Pat isn't normalized, but the beauty of it
// is that it doesn't matter
match pat.kind {
PatKind::Missing => unreachable!(),
PatKind::Wild => self.word("_"),
PatKind::Never => self.word("!"),
PatKind::Binding(BindingMode(by_ref, mutbl), _, ident, sub) => {
if mutbl.is_mut() {
self.word_nbsp("mut");
}

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

Program output

error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg
 --> /tmp/icemaker_global_tempdir.8cLPxVg6gHgk/rustc_testrunner_tmpdir_reporting.IGBaN0RkYuEa/mvce.rs:4:27
  |
4 |             fn str(_: u8, ...) {}
  |                           ^^^

error[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.8cLPxVg6gHgk/rustc_testrunner_tmpdir_reporting.IGBaN0RkYuEa/mvce.rs:6:9
  |
6 |         T,
  |         ^ not found in this scope

error[E0658]: C-variadic functions are unstable
 --> /tmp/icemaker_global_tempdir.8cLPxVg6gHgk/rustc_testrunner_tmpdir_reporting.IGBaN0RkYuEa/mvce.rs:4:13
  |
4 |             fn str(_: u8, ...) {}
  |             ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information
  = help: add `#![feature(c_variadic)]` to the crate attributes to enable
  = note: this compiler was built on 2025-04-10; consider upgrading it if it is out of date

error[E0109]: const and type arguments are not allowed on builtin type `str`
 --> /tmp/icemaker_global_tempdir.8cLPxVg6gHgk/rustc_testrunner_tmpdir_reporting.IGBaN0RkYuEa/mvce.rs:3:9
  |
2 |       let str::<
  |           --- not allowed on builtin type `str`
3 | /         {
4 | |             fn str(_: u8, ...) {}
5 | |         },
  | |_________^
6 |           T,
  |           ^ const and type arguments not allowed
  |
help: primitive type `str` doesn't have generic parameters
  |
2 -     let str::<
3 -         {
4 -             fn str(_: u8, ...) {}
5 -         },
6 -         T,
7 -     >::as_bytes;
2 +     let str::as_bytes;
  |


thread 'rustc' panicked at compiler/rustc_hir_pretty/src/lib.rs:1877:33:
internal error: entered unreachable code
stack backtrace:
   0:     0x763eb66c1e03 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9ca49ca68a18091b
   1:     0x763eb6e06091 - core::fmt::write::h2418e09b9d29127a
   2:     0x763eb821ae91 - std::io::Write::write_fmt::h0f95a0e3a4c37b4a
   3:     0x763eb66c1c62 - std::sys::backtrace::BacktraceLock::print::h9ad548cd689c6699
   4:     0x763eb66c574a - std::panicking::default_hook::{{closure}}::habb2c2e281b445e9
   5:     0x763eb66c52cf - std::panicking::default_hook::h0845fb2b84f54f34
   6:     0x763eb5718493 - std[2e1d6b8150c8c11c]::panicking::update_hook::<alloc[3b51140730c579b1]::boxed::Box<rustc_driver_impl[f859114250045cdc]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x763eb66c5fc3 - std::panicking::rust_panic_with_hook::h212b30fc071b3a78
   8:     0x763eb66c5c86 - std::panicking::begin_panic_handler::{{closure}}::h8528c01db276ff8e
   9:     0x763eb66c22c9 - std::sys::backtrace::__rust_end_short_backtrace::h62ec0d4df491ab84
  10:     0x763eb66c597d - __rustc[fcdd27f500437e9b]::rust_begin_unwind
  11:     0x763eb3085fb0 - core::panicking::panic_fmt::h6ae10fa7d4aa0d24
  12:     0x763eb308b51c - core::panicking::panic::h329152eda98144a1
  13:     0x763eb594a829 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_pat
  14:     0x763eb573a610 - <rustc_middle[3581fa90ed31b3db]::ty::context::TyCtxt as rustc_hir_pretty[6e5a4511ca1b1145]::PpAnn>::nested
  15:     0x763eb594b499 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_fn::{closure#0}
  16:     0x763eb594b1f9 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_fn
  17:     0x763eb5945f21 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_item
  18:     0x763eb573a610 - <rustc_middle[3581fa90ed31b3db]::ty::context::TyCtxt as rustc_hir_pretty[6e5a4511ca1b1145]::PpAnn>::nested
  19:     0x763eb59480d3 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_stmt
  20:     0x763eb5948203 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_block_maybe_unclosed
  21:     0x763eb7d5ae34 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_expr
  22:     0x763eb573a610 - <rustc_middle[3581fa90ed31b3db]::ty::context::TyCtxt as rustc_hir_pretty[6e5a4511ca1b1145]::PpAnn>::nested
  23:     0x763eb59484ce - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_const_arg
  24:     0x763eb8af2e68 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_generic_args.cold
  25:     0x763eb7d5c72b - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_path::<rustc_hir[3e8a6ed28d799bdb]::def::Res>
  26:     0x763eb7d5c87f - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_type
  27:     0x763eb83f9007 - <rustc_hir_pretty[6e5a4511ca1b1145]::State>::print_qpath.warm
  28:     0x763eb5944a18 - rustc_hir_pretty[6e5a4511ca1b1145]::qpath_to_string
  29:     0x763eb5ad7943 - rustc_hir_typeck[6ebdfb08463cea8e]::report_unexpected_variant_res
  30:     0x763eb70d08d6 - <rustc_hir_typeck[6ebdfb08463cea8e]::fn_ctxt::FnCtxt>::check_pat_path
  31:     0x763eb70cd397 - <rustc_hir_typeck[6ebdfb08463cea8e]::fn_ctxt::FnCtxt>::check_pat
  32:     0x763eb70ca291 - <rustc_hir_typeck[6ebdfb08463cea8e]::fn_ctxt::FnCtxt>::check_decl
  33:     0x763eb7a6c115 - <rustc_hir_typeck[6ebdfb08463cea8e]::fn_ctxt::FnCtxt>::check_expr_block
  34:     0x763eb7a72b3e - <rustc_hir_typeck[6ebdfb08463cea8e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35:     0x763eb70beb04 - rustc_hir_typeck[6ebdfb08463cea8e]::check::check_fn
  36:     0x763eb70ac01a - rustc_hir_typeck[6ebdfb08463cea8e]::typeck_with_inspect::{closure#0}
  37:     0x763eb70aad36 - rustc_query_impl[fd25b577ebc0dc7e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fd25b577ebc0dc7e]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3581fa90ed31b3db]::query::erase::Erased<[u8; 8usize]>>
  38:     0x763eb70886ac - rustc_query_system[88e79831c068c68c]::query::plumbing::try_execute_query::<rustc_query_impl[fd25b577ebc0dc7e]::DynamicConfig<rustc_data_structures[3ccb0d2300225387]::vec_cache::VecCache<rustc_span[f9510d3c29ad6ccf]::def_id::LocalDefId, rustc_middle[3581fa90ed31b3db]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[88e79831c068c68c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[fd25b577ebc0dc7e]::plumbing::QueryCtxt, false>
  39:     0x763eb708810b - rustc_query_impl[fd25b577ebc0dc7e]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  40:     0x763eb7086cbe - rustc_hir_analysis[47a3363b9af086e3]::check_crate
  41:     0x763eb7865a23 - rustc_interface[d6d362be4ac01fe7]::passes::run_required_analyses
  42:     0x763eb7d10e9e - rustc_interface[d6d362be4ac01fe7]::passes::analysis
  43:     0x763eb7d10e73 - rustc_query_impl[fd25b577ebc0dc7e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fd25b577ebc0dc7e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3581fa90ed31b3db]::query::erase::Erased<[u8; 0usize]>>
  44:     0x763eb7d1683d - rustc_query_system[88e79831c068c68c]::query::plumbing::try_execute_query::<rustc_query_impl[fd25b577ebc0dc7e]::DynamicConfig<rustc_query_system[88e79831c068c68c]::query::caches::SingleCache<rustc_middle[3581fa90ed31b3db]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[fd25b577ebc0dc7e]::plumbing::QueryCtxt, false>
  45:     0x763eb7d16538 - rustc_query_impl[fd25b577ebc0dc7e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x763eb803eccb - rustc_interface[d6d362be4ac01fe7]::passes::create_and_enter_global_ctxt::<core[49b7d9c0499c6ca0]::option::Option<rustc_interface[d6d362be4ac01fe7]::queries::Linker>, rustc_driver_impl[f859114250045cdc]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  47:     0x763eb7f772b9 - rustc_interface[d6d362be4ac01fe7]::interface::run_compiler::<(), rustc_driver_impl[f859114250045cdc]::run_compiler::{closure#0}>::{closure#1}
  48:     0x763eb7d5e4c5 - std[2e1d6b8150c8c11c]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d6d362be4ac01fe7]::util::run_in_thread_with_globals<rustc_interface[d6d362be4ac01fe7]::util::run_in_thread_pool_with_globals<rustc_interface[d6d362be4ac01fe7]::interface::run_compiler<(), rustc_driver_impl[f859114250045cdc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  49:     0x763eb7d5edab - <<std[2e1d6b8150c8c11c]::thread::Builder>::spawn_unchecked_<rustc_interface[d6d362be4ac01fe7]::util::run_in_thread_with_globals<rustc_interface[d6d362be4ac01fe7]::util::run_in_thread_pool_with_globals<rustc_interface[d6d362be4ac01fe7]::interface::run_compiler<(), rustc_driver_impl[f859114250045cdc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[49b7d9c0499c6ca0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x763eb7d601b7 - std::sys::pal::unix::thread::Thread::new::thread_start::h645c0fe284e947bb
  51:     0x763eb1ca370a - <unknown>
  52:     0x763eb1d27aac - <unknown>
  53:                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.88.0-nightly (7d7de5bf3 2025-04-10) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions