rust-lang / rust-lang/rust

ICE:rustc panicked at compiler\rustc_mir_transform\src\validate.rs:1560:30

Open
#140,850 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The code is generated by a fuzzer and reduced manually and I tried to search similar issue but got no results.
My apologies if this is a repetitive question

Code
//-Z validate-mir
fn A() -> impl {
    while A() {}
    loop {}
}
fn main() {}
Meta

rustc --version --verbose:

rustc 1.88.0-nightly (50aa04180 2025-05-08)
binary: rustc
commit-hash: 50aa04180709189a03dde5fd1c05751b2625ed37
commit-date: 2025-05-08
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.4
Error output
error: at least one trait must be specified
    |
177 | fn A() -> impl {
    |           ^^^^

error: internal compiler error: compiler\rustc_mir_transform\src\validate.rs:1560:30: unhandled type: Alias(Opaque, AliasTy { args: [], def_id: DefId(0:4 ~ test[354f]::A::{opaque#0}), .. })
Backtrace

thread 'rustc' panicked at compiler\rustc_mir_transform\src\validate.rs:1560:30:
Box<dyn Any>
stack backtrace:
   0:     0x7ffd45bbd382 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffd45bbd382 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66  
   2:     0x7ffd45bbd382 - std::sys::backtrace::_print_fmt
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\sys\backtrace.rs:66
   3:     0x7ffd45bbd382 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\sys\backtrace.rs:39
   4:     0x7ffd45befb4b - core::fmt::rt::Argument::fmt
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\core\src\fmt\rt.rs:181
   5:     0x7ffd45befb4b - core::fmt::write
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\core\src\fmt\mod.rs:1446
   6:     0x7ffd45bb34d7 - std::io::default_write_fmt
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\io\mod.rs:639
   7:     0x7ffd45bb34d7 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\io\mod.rs:1914
   8:     0x7ffd45bbd1c5 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\sys\backtrace.rs:42
   9:     0x7ffd45bc2e1a - std::panicking::default_hook::closure$0
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\panicking.rs:300   
  10:     0x7ffd45bc2bb0 - std::panicking::default_hook
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\panicking.rs:327   
  11:     0x7ffd472e08d9 - core[f111e4a7ef605334]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[bc50006dd5ee5521]::Level, &str), usize), <((rustc_lint_defs[bc50006dd5ee5521]::Level, &str), usize) as core[f111e4a7ef605334]::cmp::PartialOrd>::lt>
  12:     0x7ffd45bc3aae - std::panicking::rust_panic_with_hook
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\panicking.rs:841
  13:     0x7ffd48b737d3 - RINvNtNtNtNtCskHcYUSqe9DI_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCsgBC9fiOAFQn_12rustc_errors7snippet10AnnotationENCINvMNtCsamXvYCKHpPZ_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffd48b66e79 - std[aad7a0f80ff4ecfa]::sys::backtrace::__rust_end_short_backtrace::<std[aad7a0f80ff4ecfa]::panicking::begin_panic<rustc_errors[c16db17667fbb355]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffd48b61d6f - std[aad7a0f80ff4ecfa]::panicking::begin_panic::<rustc_errors[c16db17667fbb355]::ExplicitBug>
  16:     0x7ffd48b80a55 - <rustc_errors[c16db17667fbb355]::diagnostic::BugAbort as rustc_errors[c16db17667fbb355]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffd48ac6949 - rustc_middle[22e762101f903b8f]::util::bug::span_bug_fmt::<rustc_span[590cee7fbea9b74]::span_encoding::Span>
  18:     0x7ffd48a9928d - <rustc_middle[22e762101f903b8f]::ty::consts::Const>::walk
  19:     0x7ffd48a99056 - <rustc_middle[22e762101f903b8f]::ty::consts::Const>::walk
  20:     0x7ffd48ac6842 - rustc_middle[22e762101f903b8f]::util::bug::bug_fmt
  21:     0x7ffd4613bea4 - <rustc_mir_transform[57db05d0ea21705e]::validate::Validator as rustc_mir_transform[57db05d0ea21705e]::pass_manager::MirPass>::run_pass
  22:     0x7ffd4612c743 - <rustc_mir_transform[57db05d0ea21705e]::validate::Validator as rustc_mir_transform[57db05d0ea21705e]::pass_manager::MirPass>::run_pass
  23:     0x7ffd47a21437 - <rustc_mir_transform[57db05d0ea21705e]::post_drop_elaboration::CheckLiveDrops as rustc_mir_transform[57db05d0ea21705e]::pass_manager::MirLint>::run_lint
  24:     0x7ffd46058cee - rustc_mir_transform[57db05d0ea21705e]::mir_built
  25:     0x7ffd46b0eb8b - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  26:     0x7ffd46a3bed4 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtCs4XH7gZc0tJl_21rustc_data_structures9vec_cache8VecCacheNtNtCskbO0hp1YYUt_9rustc_hir6hir_id7OwnerIdINtNtNtCs2ZN7GrsimL3_12rus
  27:     0x7ffd46b12c62 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  28:     0x7ffd46049429 - rustc_mir_transform[57db05d0ea21705e]::ffi_unwind_calls::has_ffi_unwind_calls
  29:     0x7ffd46b0da2b - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  30:     0x7ffd46a4762e - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtCs4XH7gZc0tJl_21rustc_data_structures9vec_cache8VecCacheNtNtCstCNOwk8FZ8_10rustc_span6def_id10LocalDefIdINtNtNtCs2ZN7GrsimL3_
  31:     0x7ffd46b1d840 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  32:     0x7ffd4605a491 - rustc_mir_transform[57db05d0ea21705e]::mir_promoted
  33:     0x7ffd46b0ca09 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  34:     0x7ffd46a43c21 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtCs4XH7gZc0tJl_21rustc_data_structures9vec_cache8VecCacheNtNtCstCNOwk8FZ8_10rustc_span6def_id10LocalDefIdINtNtNtCs2ZN7GrsimL3_
  35:     0x7ffd46b13212 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  36:     0x7ffd46309918 - rustc_borrowck[f94e5613ded3b3c6]::mir_borrowck
  37:     0x7ffd46b0c98b - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  38:     0x7ffd46a3bed4 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtCs4XH7gZc0tJl_21rustc_data_structures9vec_cache8VecCacheNtNtCskbO0hp1YYUt_9rustc_hir6hir_id7OwnerIdINtNtNtCs2ZN7GrsimL3_12rus
  39:     0x7ffd46b17412 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  40:     0x7ffd454015ca - <rustc_hir_analysis[7fbad424b7a1f69a]::collect::resolve_bound_vars::is_late_bound_map::AllCollector as rustc_hir[eb2b9f614ea32def]::intravisit::Visitor>::visit_opaque_ty
  41:     0x7ffd4540198a - <rustc_hir_analysis[7fbad424b7a1f69a]::collect::resolve_bound_vars::is_late_bound_map::AllCollector as rustc_hir[eb2b9f614ea32def]::intravisit::Visitor>::visit_opaque_ty
  42:     0x7ffd45739deb - <alloc[78ca1fd804cb7045]::sync::Arc<rustc_session[dc649e9a0adc57bd]::config::OutputFilenames>>::drop_slow
  43:     0x7ffd469d6e05 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs2ZN7GrsimL3_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  44:     0x7ffd457434a4 - rustc_query_impl[d652848cb58f7d7f]::query_system
  45:     0x7ffd45f2cf8d - <rustc_hir_analysis[7fbad424b7a1f69a]::collect::resolve_bound_vars::is_late_bound_map::ConstrainedCollector as rustc_hir[eb2b9f614ea32def]::intravisit::Visitor>::visit_ty
  46:     0x7ffd46b0ea00 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  47:     0x7ffd469d6e05 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs2ZN7GrsimL3_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  48:     0x7ffd46b10a66 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  49:     0x7ffd453dde2c - rustc_hir_analysis[7fbad424b7a1f69a]::check::check::check_abi_fn_ptr
  50:     0x7ffd45ef4244 - rustc_hir_analysis[7fbad424b7a1f69a]::check::wfcheck::check_well_formed
  51:     0x7ffd46b0d48b - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  52:     0x7ffd46a478ce - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtCs4XH7gZc0tJl_21rustc_data_structures9vec_cache8VecCacheNtNtCstCNOwk8FZ8_10rustc_span6def_id10LocalDefIdINtNtNtCs2ZN7GrsimL3_
  53:     0x7ffd46b1de65 - rustc_query_impl[d652848cb58f7d7f]::plumbing::query_key_hash_verify_all
  54:     0x7ffd45f04965 - rustc_hir_analysis[7fbad424b7a1f69a]::check::wfcheck::check_mod_type_wf
  55:     0x7ffd4573af0b - <alloc[78ca1fd804cb7045]::sync::Arc<rustc_session[dc649e9a0adc57bd]::config::OutputFilenames>>::drop_slow
  56:     0x7ffd45687636 - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheNtNtCstCNOwk8FZ8_10rustc_span6def_id13LocalModDefIdINtNtNtCs2ZN7GrsimL3_12rustc_middle5query5erase6Er
  57:     0x7ffd4574f630 - rustc_query_impl[d652848cb58f7d7f]::query_system
  58:     0x7ffd45f4f8fe - rustc_hir_analysis[7fbad424b7a1f69a]::check_crate
  59:     0x7ffd45c271d3 - <rustc_interface[2753224ec3fdb3d8]::passes::LintStoreExpandImpl as rustc_expand[e6543defcfeccacc]::base::LintStoreExpand>::pre_expansion_lint
  60:     0x7ffd4252da87 - rustc_interface[2753224ec3fdb3d8]::passes::analysis
  61:     0x7ffd4573dc9a - <alloc[78ca1fd804cb7045]::sync::Arc<rustc_session[dc649e9a0adc57bd]::config::OutputFilenames>>::drop_slow
  62:     0x7ffd456466ba - RINvNtNtCs1OtVrNO53sG_18rustc_query_system5query8plumbing17try_execute_queryINtCsioPD87bJVb7_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs2ZN7GrsimL3_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  63:     0x7ffd457442c3 - rustc_query_impl[d652848cb58f7d7f]::query_system
  64:     0x7ffd424eecb5 - std[aad7a0f80ff4ecfa]::sys::backtrace::__rust_begin_short_backtrace::<<std[aad7a0f80ff4ecfa]::thread::Builder>::spawn_unchecked_<ctrlc[d1d1c403957100d4]::set_handler_inner<rustc_driver_impl[66120e850aa3d048]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  65:     0x7ffd424e8f13 - std[aad7a0f80ff4ecfa]::sys::backtrace::__rust_begin_short_backtrace::<<std[aad7a0f80ff4ecfa]::thread::Builder>::spawn_unchecked_<ctrlc[d1d1c403957100d4]::set_handler_inner<rustc_driver_impl[66120e850aa3d048]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  66:     0x7ffd424e479f - RINvNtNtCseFo9rzt8nG0_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs3nk84nPWrZA_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs8LjMsns72Ye_17rustc_driver_i
  67:     0x7ffd424f3010 - std[aad7a0f80ff4ecfa]::sys::backtrace::__rust_begin_short_backtrace::<<std[aad7a0f80ff4ecfa]::thread::Builder>::spawn_unchecked_<ctrlc[d1d1c403957100d4]::set_handler_inner<rustc_driver_impl[66120e850aa3d048]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  68:     0x7ffd45bc7e1d - alloc::boxed::impl$28::call_once
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\alloc\src\boxed.rs:1966
  69:     0x7ffd45bc7e1d - alloc::boxed::impl$28::call_once
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\alloc\src\boxed.rs:1966
  70:     0x7ffd45bc7e1d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/50aa04180709189a03dde5fd1c05751b2625ed37/library\std\src\sys\pal\windows\thread.rs:56
  71:     0x7ffe20097374 - BaseThreadInitThunk
  72:     0x7ffe2057cc91 - RtlUserThreadStart

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: compiler flags: -Z validate-mir

query stack during panic:
#0 [mir_built] building MIR for `A`
#1 [has_ffi_unwind_calls] checking if `A` contains FFI-unwind calls
... and 7 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 2 previous errors

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

Start with compiler/rustc_mir_transform/src/validate.rs at line 1560 and reproduce the report using the reduced example with -Z validate-mir on the noted nightly compiler. Trace how the validator handles the reported opaque alias; done means this input no longer causes an internal compiler error and instead produces appropriate diagnostics or completes normally.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.