rust-lang / rust-lang/rust

[ICE]: `assertion failed: &vtable_entries[..vtable_entries_b.len()] == vtable_entries_b`

Open
#153,500 1 comment 0 reactions 1 assignee View on GitHub

@TaKO8Ki is already working on this.

Since Mar 10, 2026.

C-bug 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
trait Supertrait<T> {
    fn static(mut self) {}
}

trait Trait<P>: Supertrait<> {}

impl<P> Trait<P> for () {}

const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Trait<P> {
    x
}

const fn foo() -> &'static dyn Supertrait<()> {
    upcast::<()>(&())
}

const _: &'static dyn Supertrait<()> = foo();

original:

trait Supertrait<T> {
    fn static(mut self) {}
}

trait Trait<P>: Supertrait<Output = impl ReturnsSend> {}

impl<P> Trait<P> for () {}

const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Trait<P> {
    x
}

const fn foo() -> &'static dyn Supertrait<()> {
    upcast::<()>(&())
}

const _: &'static dyn Supertrait<()> = foo();

Version information

rustc 1.96.0-nightly (f82485388 2026-03-06)
binary: rustc
commit-hash: f82485388963286763f8c8a9261ac227627f6a18
commit-date: 2026-03-06
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Possibly related line of code:
https://github.com/rust-lang/rust/blob/f82485388963286763f8c8a9261ac227627f6a18/compiler/rustc_const_eval/src/interpret/cast.rs#L428-L440

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

Program output

error: expected identifier, found keyword `static`
 --> /tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs:2:8
  |
2 |     fn static(mut self) {}
  |        ^^^^^^ expected identifier, found keyword
  |
help: escape `static` to use it as an identifier
  |
2 |     fn r#static(mut self) {}
  |        ++

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs:17:46
   |
17 | const _: &'static dyn Supertrait<()> = foo();
   |                                              ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs`

error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
 --> /tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs:5:17
  |
5 | trait Trait<P>: Supertrait<> {}
  |                 ^^^^^^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> /tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs:1:7
  |
1 | trait Supertrait<T> {
  |       ^^^^^^^^^^ -
help: add missing generic argument
  |
5 | trait Trait<P>: Supertrait<T> {}
  |                            +

error[E0277]: the size for values of type `Self` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.1zEOWDZ8wIVR/rustc_testrunner_tmpdir_reporting.c3EWktKEHDaM/mvce.rs:2:19
  |
2 |     fn static(mut self) {}
  |                   ^^^^ doesn't have a size known at compile-time
  |
  = help: unsized fn params are gated as an unstable feature
help: consider further restricting `Self`
  |
2 |     fn static(mut self) where Self: Sized {}
  |                         +++++++++++++++++
help: function arguments must have a statically known size, borrowed types always have a known size
  |
2 |     fn static(mut &self) {}
  |                   +


thread 'rustc' (3572335) panicked at /rustc-dev/f82485388963286763f8c8a9261ac227627f6a18/compiler/rustc_const_eval/src/interpret/cast.rs:434:21:
assertion failed: &vtable_entries[..vtable_entries_b.len()] == vtable_entries_b
stack backtrace:
   0:     0x7f34b735df6b - <<std[1ac9ec7f151dc343]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[2185e438fa60127]::fmt::Display>::fmt
   1:     0x7f34b7a22a08 - core[2185e438fa60127]::fmt::write
   2:     0x7f34b7374f76 - <std[1ac9ec7f151dc343]::sys::stdio::unix::Stderr as std[1ac9ec7f151dc343]::io::Write>::write_fmt
   3:     0x7f34b7334058 - std[1ac9ec7f151dc343]::panicking::default_hook::{closure#0}
   4:     0x7f34b73513e3 - std[1ac9ec7f151dc343]::panicking::default_hook
   5:     0x7f34b6337e4c - std[1ac9ec7f151dc343]::panicking::update_hook::<alloc[1b3f84b8c09c25b1]::boxed::Box<rustc_driver_impl[6e789f234d303bfb]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f34b73516c2 - std[1ac9ec7f151dc343]::panicking::panic_with_hook
   7:     0x7f34b733414a - std[1ac9ec7f151dc343]::panicking::panic_handler::{closure#0}
   8:     0x7f34b7328669 - std[1ac9ec7f151dc343]::sys::backtrace::__rust_end_short_backtrace::<std[1ac9ec7f151dc343]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f34b7335b7d - __rustc[3c4f6ba47a7fa14c]::rust_begin_unwind
  10:     0x7f34b3f4543c - core[2185e438fa60127]::panicking::panic_fmt
  11:     0x7f34b3a01012 - core[2185e438fa60127]::panicking::panic
  12:     0x7f34b7e4563e - <rustc_const_eval[932f6faba1bcace8]::interpret::eval_context::InterpCx<rustc_const_eval[932f6faba1bcace8]::const_eval::machine::CompileTimeMachine>>::unsize_into_ptr::<rustc_const_eval[932f6faba1bcace8]::interpret::place::PlaceTy>
  13:     0x7f34b8acc5b6 - <rustc_const_eval[932f6faba1bcace8]::interpret::eval_context::InterpCx<rustc_const_eval[932f6faba1bcace8]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  14:     0x7f34b8a86084 - rustc_const_eval[932f6faba1bcace8]::const_eval::eval_queries::eval_to_allocation_raw_provider
  15:     0x7f34b8a84858 - rustc_query_impl[234cac1489f93c02]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7f34b80ebaca - rustc_query_impl[234cac1489f93c02]::execution::try_execute_query::<rustc_middle[6c1cd5853b8c3360]::query::caches::DefaultCache<rustc_middle[6c1cd5853b8c3360]::ty::PseudoCanonicalInput<rustc_middle[6c1cd5853b8c3360]::mir::interpret::GlobalId>, rustc_middle[6c1cd5853b8c3360]::query::erase::ErasedData<[u8; 24usize]>>, false>
  17:     0x7f34b80eb47f - rustc_query_impl[234cac1489f93c02]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7f34b80ed0af - rustc_const_eval[932f6faba1bcace8]::const_eval::eval_queries::eval_to_const_value_raw_provider
  19:     0x7f34b80ecc16 - rustc_query_impl[234cac1489f93c02]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7f34b80eb9c2 - rustc_query_impl[234cac1489f93c02]::execution::try_execute_query::<rustc_middle[6c1cd5853b8c3360]::query::caches::DefaultCache<rustc_middle[6c1cd5853b8c3360]::ty::PseudoCanonicalInput<rustc_middle[6c1cd5853b8c3360]::mir::interpret::GlobalId>, rustc_middle[6c1cd5853b8c3360]::query::erase::ErasedData<[u8; 24usize]>>, false>
  21:     0x7f34b80eb53f - rustc_query_impl[234cac1489f93c02]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7f34b8574b67 - <rustc_middle[6c1cd5853b8c3360]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[b1c64fc70d705e68]::check_crate::{closure#2}>::{closure#0}
  23:     0x7f34b85741b5 - rustc_hir_analysis[b1c64fc70d705e68]::check_crate
  24:     0x7f34b7abc79d - rustc_interface[c926bcc183cff181]::passes::analysis
  25:     0x7f34b8c82760 - rustc_query_impl[234cac1489f93c02]::execution::try_execute_query::<rustc_middle[6c1cd5853b8c3360]::query::caches::SingleCache<rustc_middle[6c1cd5853b8c3360]::query::erase::ErasedData<[u8; 0usize]>>, false>
  26:     0x7f34b8c82447 - rustc_query_impl[234cac1489f93c02]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f34b8c3da6d - rustc_interface[c926bcc183cff181]::interface::run_compiler::<(), rustc_driver_impl[6e789f234d303bfb]::run_compiler::{closure#0}>::{closure#1}
  28:     0x7f34b8c6613e - std[1ac9ec7f151dc343]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[c926bcc183cff181]::util::run_in_thread_with_globals<rustc_interface[c926bcc183cff181]::util::run_in_thread_pool_with_globals<rustc_interface[c926bcc183cff181]::interface::run_compiler<(), rustc_driver_impl[6e789f234d303bfb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x7f34b8c669e0 - <std[1ac9ec7f151dc343]::thread::lifecycle::spawn_unchecked<rustc_interface[c926bcc183cff181]::util::run_in_thread_with_globals<rustc_interface[c926bcc183cff181]::util::run_in_thread_pool_with_globals<rustc_interface[c926bcc183cff181]::interface::run_compiler<(), rustc_driver_impl[6e789f234d303bfb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2185e438fa60127]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x7f34b8c6786c - <std[1ac9ec7f151dc343]::sys::thread::unix::Thread>::new::thread_start
  31:     0x7f34b265e98b - <unknown>
  32:     0x7f34b26e2a0c - <unknown>
  33:                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.96.0-nightly (f82485388 2026-03-06) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `_`
#1 [eval_to_const_value_raw] simplifying constant for the type system `_`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

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

@rustbot label +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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.