Skip to content

ICE:rustc panicked at compiler\rustc_middle\src\ty\instance.rs:632:25 #140639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sososopy opened this issue May 4, 2025 · 0 comments
Closed

ICE:rustc panicked at compiler\rustc_middle\src\ty\instance.rs:632:25 #140639

sososopy opened this issue May 4, 2025 · 0 comments
Labels
-Zvalidate-mir Unstable option: MIR validation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sososopy
Copy link

sososopy commented May 4, 2025

Code

//-C opt-level=1 -Z validate-mir
struct A;
trait X {
}
trait Y: X {
    fn func(&self);
}
impl Y for A {
}
fn main() {
    let a = &A as &dyn Y;
    let b = a as &dyn X;
}

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (d6a325d93 2025-05-03)
binary: rustc
commit-hash: d6a325d93a84077580c677f89affbe45682606c3
commit-date: 2025-05-03
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.4

Error output

error[E0277]: the trait bound `A: X` is not satisfied
    |
282 | impl Y for A {
    |            ^ the trait `X` is not implemented for `A`
    |
help: this trait has no implementations, consider adding one
    |
277 | trait X {
    | ^^^^^^^
note: required by a bound in `Y`
    |
279 | trait Y: X {
    |          ^ required by this bound in `Y`

error[E0046]: not all trait items implemented, missing: `func`
    |
280 |     fn func(&self);
    |     --------------- `func` from trait
281 | }
282 | impl Y for A {
    | ^^^^^^^^^^^^ missing `func` in implementation

warning: unused variable: `b`
    |
286 |     let b = a as &dyn X;
    |         ^ help: if this is intentional, prefix it with an underscore: `_b`
    |
    = note: `#[warn(unused_variables)]` on by default

error: internal compiler error: compiler\rustc_middle\src\ty\instance.rs:632:25: failed to resolve instance for <A as Y>::func: Err(
                                    ErrorGuaranteed(
                                        (),
                                    ),
                                )
    |
280 |     fn func(&self);
    |     ^^^^^^^^^^^^^^^

Backtrace

thread 'rustc' panicked at compiler\rustc_middle\src\ty\instance.rs:632:25:
Box<dyn Any>
stack backtrace:
   0:     0x7ffcb08ad4c2 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7ffcb08ad4c2 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffcb08ad4c2 - std::sys::backtrace::_print_fmt
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\sys\backtrace.rs:66
   3:     0x7ffcb08ad4c2 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\sys\backtrace.rs:39
   4:     0x7ffcb08dfccb - core::fmt::rt::Argument::fmt
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\core\src\fmt\rt.rs:181
   5:     0x7ffcb08dfccb - core::fmt::write
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\core\src\fmt\mod.rs:1446
   6:     0x7ffcb08a3577 - std::io::default_write_fmt
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\io\mod.rs:639
   7:     0x7ffcb08a3577 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\io\mod.rs:1914
   8:     0x7ffcb08ad305 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\sys\backtrace.rs:42
   9:     0x7ffcb08b2faa - std::panicking::default_hook::closure$0
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\panicking.rs:300
  10:     0x7ffcb08b2d40 - std::panicking::default_hook
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\panicking.rs:327
  11:     0x7ffcb1fb40c9 - core[87a27484b78f7475]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[b0c94f99b9e7b658]::Level, &str), usize), <((rustc_lint_defs[b0c94f99b9e7b658]::Level, &str), usize) as core[87a27484b78f7475]::cmp::PartialOrd>::lt>
  12:     0x7ffcb08b3c3e - std::panicking::rust_panic_with_hook
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\panicking.rs:841
  13:     0x7ffcb3829703 - RINvNtNtNtNtCsbDYK7ZPCyAj_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCs6SLwrM4uBLa_12rustc_errors7snippet10AnnotationENCINvMNtCs1unwqmfRHjA_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
  14:     0x7ffcb381cda9 - std[60b31a4c47ffc37a]::sys::backtrace::__rust_end_short_backtrace::<std[60b31a4c47ffc37a]::panicking::begin_panic<rustc_errors[502ca62a62c32c12]::ExplicitBug>::{closure#0}, !>
  15:     0x7ffcb3817c9f - std[60b31a4c47ffc37a]::panicking::begin_panic::<rustc_errors[502ca62a62c32c12]::ExplicitBug>
  16:     0x7ffcb3836995 - <rustc_errors[502ca62a62c32c12]::diagnostic::BugAbort as rustc_errors[502ca62a62c32c12]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  17:     0x7ffcb36cd2df - <hashbrown[70b43471957514b2]::raw::RawTable<((rustc_middle[1480b13a6d85428b]::mir::interpret::GlobalAlloc, usize), rustc_middle[1480b13a6d85428b]::mir::interpret::AllocId)>>::reserve_rehash::<hashbrown[70b43471957514b2]::map::make_hasher<(rustc_middle[1480b13a6d85428b]::mir::interpret::GlobalAlloc, usize), rustc_middle[1480b13a6d85428b]::mir::interpret::AllocId, rustc_hash[530908e490a46e17]::FxBuildHasher>::{closure#0}>
  18:     0x7ffcb377c9c6 - rustc_middle[1480b13a6d85428b]::util::bug::span_bug_fmt::<rustc_span[754db6c0dee538d5]::span_encoding::Span>
  19:     0x7ffcb374f92d - <rustc_middle[1480b13a6d85428b]::ty::consts::Const>::walk
  20:     0x7ffcb374f6f6 - <rustc_middle[1480b13a6d85428b]::ty::consts::Const>::walk
  21:     0x7ffcb377c929 - rustc_middle[1480b13a6d85428b]::util::bug::span_bug_fmt::<rustc_span[754db6c0dee538d5]::span_encoding::Span>
  22:     0x7ffcb1e606d5 - <rustc_middle[1480b13a6d85428b]::ty::instance::Instance>::expect_resolve
  23:     0x7ffcb0726618 - <rustc_middle[1480b13a6d85428b]::ty::instance::Instance>::expect_resolve_for_vtable
  24:     0x7ffcb0533713 - rustc_trait_selection[f74037769114fe9a]::traits::vtable::vtable_entries
  25:     0x7ffcb0532858 - rustc_trait_selection[f74037769114fe9a]::traits::vtable::vtable_entries
  26:     0x7ffcb042cd27 - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtCs3FUrNoRJhAC_21rustc_data_structures9vec_cache8VecCacheNtNtCsa4p3ycDgZPl_10rustc_span6def_id8CrateNumINtNtNtCs1L8owUfIxip_12
  27:     0x7ffcb04024a0 - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtCs3FUrNoRJhAC_21rustc_data_structures9vec_cache8VecCacheNtNtCsa4p3ycDgZPl_10rustc_span6def_id8CrateNumINtNtNtCs1L8owUfIxip_12
  28:     0x7ffcb036d5b8 - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs5cavw6AphmO_13rustc_type_ir9predicate8TraitRefNtNtNtCs1L8owUfIxip_12rustc_middle2ty7context6Ty
  29:     0x7ffcb0448219 - rustc_query_impl[c065d24221bafc56]::query_system
  30:     0x7ffcb26aa290 - <rustc_mir_transform[cda48affa4b115dd]::errors::FfiUnwindCall as rustc_errors[502ca62a62c32c12]::diagnostic::LintDiagnostic<()>>::decorate_lint
  31:     0x7ffcb01551e3 - RINvNtNtNtNtCsbDYK7ZPCyAj_4core5slice4sort6stable9quicksort9quicksortTNtNtCs1L8owUfIxip_12rustc_middle3mir8LocationNtNtB18_9statement9StatementENCINvMNtCs1unwqmfRHjA_5alloc5sliceSB15_11sort_by_keyINtNtBa_3cmp7ReverseB16_ENCNvNtCshED9wOWuMxJ_19rustc_mir_tra
  32:     0x7ffcb01540fa - RINvNtNtNtNtCsbDYK7ZPCyAj_4core5slice4sort6stable9quicksort9quicksortTNtNtCs1L8owUfIxip_12rustc_middle3mir8LocationNtNtB18_9statement9StatementENCINvMNtCs1unwqmfRHjA_5alloc5sliceSB15_11sort_by_keyINtNtBa_3cmp7ReverseB16_ENCNvNtCshED9wOWuMxJ_19rustc_mir_tra
  33:     0x7ffcb0e63049 - <rustc_mir_transform[cda48affa4b115dd]::inline::NormalInliner as rustc_mir_transform[cda48affa4b115dd]::inline::Inliner>::check_callee_mir_body
  34:     0x7ffcb0da25c7 - <rustc_mir_transform[cda48affa4b115dd]::gvn::VnState as rustc_middle[1480b13a6d85428b]::mir::visit::MutVisitor>::visit_statement
  35:     0x7ffcb0e709d5 - <rustc_mir_transform[cda48affa4b115dd]::gvn::GVN as rustc_mir_transform[cda48affa4b115dd]::pass_manager::MirPass>::run_pass
  36:     0x7ffcb0d2d227 - <rustc_mir_transform[cda48affa4b115dd]::simplify::SimplifyCfg as rustc_mir_transform[cda48affa4b115dd]::pass_manager::MirPass>::run_pass
  37:     0x7ffcb0d5ec8b - rustc_mir_transform[cda48affa4b115dd]::run_analysis_to_runtime_passes
  38:     0x7ffcb0d5f53f - rustc_mir_transform[cda48affa4b115dd]::optimized_mir
  39:     0x7ffcb17e9d20 - rustc_query_impl[c065d24221bafc56]::plumbing::query_key_hash_verify_all
  40:     0x7ffcb16b648b - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtB4_6caches10DefIdCacheINtNtNtCs1L8owUfIxip_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3r_KB3r_ENtNtB1f_8plumbing9QueryCtxt
  41:     0x7ffcb17f02a4 - rustc_query_impl[c065d24221bafc56]::plumbing::query_key_hash_verify_all
  42:     0x7ffcb1eb9ba9 - <rustc_middle[1480b13a6d85428b]::ty::context::TyCtxt>::instance_mir
  43:     0x7ffcb091eec0 - rustc_interface[86b4c53d29a74bab]::passes::resolver_for_lowering_raw
  44:     0x7ffcad224717 - rustc_interface[86b4c53d29a74bab]::passes::analysis
  45:     0x7ffcb0430b3a - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtCs3FUrNoRJhAC_21rustc_data_structures9vec_cache8VecCacheNtNtCsa4p3ycDgZPl_10rustc_span6def_id8CrateNumINtNtNtCs1L8owUfIxip_12
  46:     0x7ffcb033982d - RINvNtNtCskNl1B5Z2lPN_18rustc_query_system5query8plumbing17try_execute_queryINtCsgw7YxB7xM2g_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs1L8owUfIxip_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  47:     0x7ffcb0437133 - rustc_query_impl[c065d24221bafc56]::query_system
  48:     0x7ffcad1deb0f - std[60b31a4c47ffc37a]::sys::backtrace::__rust_begin_short_backtrace::<<std[60b31a4c47ffc37a]::thread::Builder>::spawn_unchecked_<ctrlc[3c1ab0e88be51457]::set_handler_inner<rustc_driver_impl[4bf9a847fe62d732]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  49:     0x7ffcad1d8a13 - std[60b31a4c47ffc37a]::sys::backtrace::__rust_begin_short_backtrace::<<std[60b31a4c47ffc37a]::thread::Builder>::spawn_unchecked_<ctrlc[3c1ab0e88be51457]::set_handler_inner<rustc_driver_impl[4bf9a847fe62d732]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  50:     0x7ffcad1d3b2f - RINvNtNtCs8iJfnLcCENa_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsbz2kvDINMEx_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs6wpGHyykUq4_17rustc_driver_i
  51:     0x7ffcad1e2e60 - std[60b31a4c47ffc37a]::sys::backtrace::__rust_begin_short_backtrace::<<std[60b31a4c47ffc37a]::thread::Builder>::spawn_unchecked_<ctrlc[3c1ab0e88be51457]::set_handler_inner<rustc_driver_impl[4bf9a847fe62d732]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  52:     0x7ffcb08b7fad - alloc::boxed::impl$28::call_once
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\alloc\src\boxed.rs:1966
  53:     0x7ffcb08b7fad - alloc::boxed::impl$28::call_once
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\alloc\src\boxed.rs:1966
  54:     0x7ffcb08b7fad - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/d6a325d93a84077580c677f89affbe45682606c3/library\std\src\sys\pal\windows\thread.rs:56
  55:     0x7ffd826a7374 - BaseThreadInitThunk
  56:     0x7ffd8345cc91 - 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: please attach the file at `rustc-ice-2025-05-04T14_44_52-31872.txt` to your bug report

note: compiler flags: -C opt-level=1 -Z validate-mir

query stack during panic:
#0 [vtable_entries] finding all vtable entries for trait `Y`
#1 [optimized_mir] optimizing MIR for `main`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 3 previous errors; 1 warning emitted

@sososopy sososopy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 4, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 4, 2025
@fmease fmease added -Zvalidate-mir Unstable option: MIR validation requires-nightly This issue requires a nightly compiler in some way. labels May 4, 2025
@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants