Skip to content

[ICE]: vtable : None from prepare_vtable_segments() #151330

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
trait Supertrait<T> {}

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(&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.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

}
}
ControlFlow::Continue(())
}
};
prepare_vtable_segments(tcx, source_principal, vtable_segment_callback).unwrap()
}
pub(super) fn provide(providers: &mut Providers) {
*providers = Providers {
own_existential_vtable_entries,
vtable_entries,

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

Program output

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

error[E0107]: missing generics for trait `Supertrait`
 --> /tmp/icemaker_global_tempdir.K5SjLYH7a8mL/rustc_testrunner_tmpdir_reporting.EuEghOYFieqJ/mvce.rs:3:17
  |
3 | trait Trait<P>: Supertrait {}
  |                 ^^^^^^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `T`
 --> /tmp/icemaker_global_tempdir.K5SjLYH7a8mL/rustc_testrunner_tmpdir_reporting.EuEghOYFieqJ/mvce.rs:1:7
  |
1 | trait Supertrait<T> {}
  |       ^^^^^^^^^^ -
help: add missing generic argument
  |
3 | trait Trait<P>: Supertrait<T> {}
  |                           +++


thread 'rustc' (2079460) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_trait_selection/src/traits/vtable.rs:437:77:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f354f433fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
   1:     0x7f354fa0e2c8 - core[7477a31a1a34cc49]::fmt::write
   2:     0x7f354f44a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
   3:     0x7f354f40a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
   4:     0x7f354f427703 - std[287527946f71f0bc]::panicking::default_hook
   5:     0x7f354e3fbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f354f4279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
   7:     0x7f354f40a13a - std[287527946f71f0bc]::panicking::panic_handler::{closure#0}
   8:     0x7f354f400dc9 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f354f40bbdd - __rustc[5ec7081ce87b032f]::rust_begin_unwind
  10:     0x7f354bf0cfbc - core[7477a31a1a34cc49]::panicking::panic_fmt
  11:     0x7f354bbe10a2 - core[7477a31a1a34cc49]::panicking::panic
  12:     0x7f354c27c749 - core[7477a31a1a34cc49]::option::unwrap_failed
  13:     0x7f354f259c40 - rustc_trait_selection[9fee51d8a10a777c]::traits::vtable::supertrait_vtable_slot
  14:     0x7f354ee153e6 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::supertrait_vtable_slot::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 16usize]>>
  15:     0x7f354ef17f59 - <rustc_query_impl[f20b8284200e680a]::query_impl::supertrait_vtable_slot::dynamic_query::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(rustc_middle[725063e074f29df]::ty::context::TyCtxt, (rustc_middle[725063e074f29df]::ty::Ty, rustc_middle[725063e074f29df]::ty::Ty))>>::call_once
  16:     0x7f354ee28596 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::DefaultCache<(rustc_middle[725063e074f29df]::ty::Ty, rustc_middle[725063e074f29df]::ty::Ty), rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  17:     0x7f354eea1340 - rustc_query_impl[f20b8284200e680a]::query_impl::supertrait_vtable_slot::get_query_non_incr::__rust_end_short_backtrace
  18:     0x7f354ff9e418 - <rustc_const_eval[b948c5b36ae67fb9]::interpret::eval_context::InterpCx<rustc_const_eval[b948c5b36ae67fb9]::const_eval::machine::CompileTimeMachine>>::unsize_into_ptr::<rustc_const_eval[b948c5b36ae67fb9]::interpret::place::PlaceTy>
  19:     0x7f3550b00904 - <rustc_const_eval[b948c5b36ae67fb9]::interpret::eval_context::InterpCx<rustc_const_eval[b948c5b36ae67fb9]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  20:     0x7f3550aba0cd - rustc_const_eval[b948c5b36ae67fb9]::const_eval::eval_queries::eval_to_allocation_raw_provider
  21:     0x7f3550ab847e - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>
  22:     0x7f3550ab7ba5 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::DefaultCache<rustc_middle[725063e074f29df]::ty::PseudoCanonicalInput<rustc_middle[725063e074f29df]::mir::interpret::GlobalId>, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  23:     0x7f3550ab7749 - rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f3550ab3504 - rustc_const_eval[b948c5b36ae67fb9]::const_eval::eval_queries::eval_to_const_value_raw_provider
  25:     0x7f3550ab3080 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>
  26:     0x7f3550ab1c8a - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::DefaultCache<rustc_middle[725063e074f29df]::ty::PseudoCanonicalInput<rustc_middle[725063e074f29df]::mir::interpret::GlobalId>, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  27:     0x7f3550ab17f3 - rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f35505401b0 - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[1a80394817eddfdd]::check_crate::{closure#2}>::{closure#0}
  29:     0x7f355053f7c4 - rustc_hir_analysis[1a80394817eddfdd]::check_crate
  30:     0x7f354fb493db - rustc_interface[5c48368f5debe80d]::passes::analysis
  31:     0x7f354fb49035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f3550ba4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  33:     0x7f3550ba49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f3550d82c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  35:     0x7f3550bf5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7f3550b5aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7f3550b5a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f3550b5c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7f354a49698b - <unknown>
  40:     0x7f354a51a9cc - <unknown>
  41:                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.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [supertrait_vtable_slot] finding the slot within vtable for trait object `dyn Supertrait<()>` vtable ptr during trait upcasting coercion from `dyn Trait<()>` vtable
#1 [eval_to_allocation_raw] const-evaluating + checking `_`
#2 [eval_to_const_value_raw] simplifying constant for the type system `_`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors

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

@rustbot label +WG-trait-system-refactor

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions