rust-lang / rust-lang/rust

[ICE]: `prepare_vtable_segments()` is `None`

Open
#153,368 0 comments 0 reactions 1 assignee View on GitHub

@ShoyuVanilla is already working on this.

Since Mar 4, 2026.

C-bug I-ICE S-bug-has-test S-has-mcve 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 Foo: Bar<T> + Bar<u32> {}
trait Bar<T> {
    fn bar(self) -> T;
}

fn test_infer_version(x: &dyn Foo) {
    x.bar()
}

original:

trait Foo: Bar<T> + Bar<u32> {}
trait Bar<T> {
    fn bar(self) -> T;
}

fn test_infer_version(x: &dyn Foo) {
    x.bar()
}

fn main() {}

Version information

rustc 1.96.0-nightly (d2218f5f5 2026-03-03)
binary: rustc
commit-hash: d2218f5f5ca3f502772ec4cb69fc2ee44e096512
commit-date: 2026-03-03
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/d2218f5f5ca3f502772ec4cb69fc2ee44e096512/compiler/rustc_trait_selection/src/traits/vtable.rs#L362-L374

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

Program output

error[E0425]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.P6C3K8M8uTzI/rustc_testrunner_tmpdir_reporting.XSHvcksJG6gN/mvce.rs:1:16
  |
1 | trait Foo: Bar<T> + Bar<u32> {}
  |                ^ not found in this scope

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.P6C3K8M8uTzI/rustc_testrunner_tmpdir_reporting.XSHvcksJG6gN/mvce.rs:8:2
  |
8 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.P6C3K8M8uTzI/rustc_testrunner_tmpdir_reporting.XSHvcksJG6gN/mvce.rs`


thread 'rustc' (833187) panicked at /rustc-dev/d2218f5f5ca3f502772ec4cb69fc2ee44e096512/compiler/rustc_trait_selection/src/traits/vtable.rs:368:77:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f1e84b62aab - <<std[76599d2169901dc8]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d5ffb84325ed5c2a]::fmt::Display>::fmt
   1:     0x7f1e852228c8 - core[d5ffb84325ed5c2a]::fmt::write
   2:     0x7f1e84b79ab6 - <std[76599d2169901dc8]::sys::stdio::unix::Stderr as std[76599d2169901dc8]::io::Write>::write_fmt
   3:     0x7f1e84b38b88 - std[76599d2169901dc8]::panicking::default_hook::{closure#0}
   4:     0x7f1e84b55f13 - std[76599d2169901dc8]::panicking::default_hook
   5:     0x7f1e83b424cc - std[76599d2169901dc8]::panicking::update_hook::<alloc[f847baa7d3d2ac55]::boxed::Box<rustc_driver_impl[ffd722fd6c32666a]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f1e84b561f2 - std[76599d2169901dc8]::panicking::panic_with_hook
   7:     0x7f1e84b38c7a - std[76599d2169901dc8]::panicking::panic_handler::{closure#0}
   8:     0x7f1e84b2f979 - std[76599d2169901dc8]::sys::backtrace::__rust_end_short_backtrace::<std[76599d2169901dc8]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f1e84b3a6ad - __rustc[7dea9537d06e225e]::rust_begin_unwind
  10:     0x7f1e8171975c - core[d5ffb84325ed5c2a]::panicking::panic_fmt
  11:     0x7f1e81202052 - core[d5ffb84325ed5c2a]::panicking::panic
  12:     0x7f1e8190ca29 - core[d5ffb84325ed5c2a]::option::unwrap_failed
  13:     0x7f1e861fca2d - rustc_trait_selection[502c21a12406236f]::traits::vtable::first_method_vtable_slot
  14:     0x7f1e862006b2 - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_type_ir[6a4b9ee69e1ff834]::predicate::TraitRef<rustc_middle[7c9cbe436035c5a4]::ty::context::TyCtxt>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 8usize]>>, false>
  15:     0x7f1e862003dd - rustc_query_impl[89f9236b2ac04da0]::query_impl::first_method_vtable_slot::execute_query_non_incr::__rust_end_short_backtrace
  16:     0x7f1e854cf3ed - rustc_ty_utils[23782f25fc8ac972]::instance::resolve_instance_raw
  17:     0x7f1e854cb8df - rustc_query_impl[89f9236b2ac04da0]::query_impl::resolve_instance_raw::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f1e854ca99c - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::DefaultCache<rustc_middle[7c9cbe436035c5a4]::ty::PseudoCanonicalInput<(rustc_span[8a71b77c74bc13cb]::def_id::DefId, &rustc_middle[7c9cbe436035c5a4]::ty::list::RawList<(), rustc_middle[7c9cbe436035c5a4]::ty::generic_args::GenericArg>)>, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 32usize]>>, false>
  19:     0x7f1e854ca5c3 - rustc_query_impl[89f9236b2ac04da0]::query_impl::resolve_instance_raw::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f1e855a97a2 - <rustc_middle[7c9cbe436035c5a4]::ty::instance::Instance>::try_resolve
  21:     0x7f1e855a5892 - <rustc_mir_transform[c7b522523fe3a5eb]::check_call_recursion::CheckCallRecursion as rustc_mir_transform[c7b522523fe3a5eb]::pass_manager::MirLint>::run_lint
  22:     0x7f1e8520b72d - rustc_mir_transform[c7b522523fe3a5eb]::mir_built
  23:     0x7f1e8536d18a - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_data_structures[79f5f180de225010]::vec_cache::VecCache<rustc_span[8a71b77c74bc13cb]::def_id::LocalDefId, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[7c9cbe436035c5a4]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7f1e8536cc83 - rustc_query_impl[89f9236b2ac04da0]::query_impl::mir_built::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7f1e81fb926c - rustc_mir_build[10e3059a1c65a42d]::check_unsafety::check_unsafety
  26:     0x7f1e8536b99f - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_data_structures[79f5f180de225010]::vec_cache::VecCache<rustc_span[8a71b77c74bc13cb]::def_id::LocalDefId, rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 0usize]>, rustc_middle[7c9cbe436035c5a4]::dep_graph::graph::DepNodeIndex>, false>
  27:     0x7f1e8536b6f6 - rustc_query_impl[89f9236b2ac04da0]::query_impl::check_unsafety::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7f1e8536a9ea - <rustc_middle[7c9cbe436035c5a4]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[400bc27e64bfd912]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  29:     0x7f1e8536a02f - rustc_interface[400bc27e64bfd912]::passes::analysis
  30:     0x7f1e8643175c - rustc_query_impl[89f9236b2ac04da0]::execution::try_execute_query::<rustc_middle[7c9cbe436035c5a4]::query::caches::SingleCache<rustc_middle[7c9cbe436035c5a4]::query::erase::ErasedData<[u8; 0usize]>>, false>
  31:     0x7f1e864314bb - rustc_query_impl[89f9236b2ac04da0]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f1e863eda2d - rustc_interface[400bc27e64bfd912]::interface::run_compiler::<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7f1e863d20be - std[76599d2169901dc8]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7f1e863d2720 - <std[76599d2169901dc8]::thread::lifecycle::spawn_unchecked<rustc_interface[400bc27e64bfd912]::util::run_in_thread_with_globals<rustc_interface[400bc27e64bfd912]::util::run_in_thread_pool_with_globals<rustc_interface[400bc27e64bfd912]::interface::run_compiler<(), rustc_driver_impl[ffd722fd6c32666a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[d5ffb84325ed5c2a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f1e863d35ac - <std[76599d2169901dc8]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7f1e7fe5998b - <unknown>
  37:     0x7f1e7fedda0c - <unknown>
  38:                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 (d2218f5f5 2026-03-03) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [first_method_vtable_slot] finding the slot within the vtable of `dyn Foo` for the implementation of `Bar`
#1 [resolve_instance_raw] resolving instance `<dyn Foo as Bar<()>>::bar`
#2 [mir_built] building MIR for `test_infer_version`
#3 [check_unsafety] unsafety-checking `test_infer_version`
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors

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

@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.