Skip to content

[ICE]: prepare_vtable_segments() is None #153368

Closed

Description

@matthiaskrgr

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:

}
}
ControlFlow::Continue(())
}
};
prepare_vtable_segments(tcx, source_principal, vtable_segment_callback).unwrap()
}
/// Given a `dyn Subtrait` and `dyn Supertrait` trait object, find the slot of
/// the trait vptr in the subtrait's vtable.
///
/// A return value of `None` means that the original vtable can be reused.

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

Activity

  1. added
    I-ICE
    T-compiler
    C-bug
    on Mar 3, 2026
  2. added
    needs-triage
    WG-trait-system-refactor
    on Mar 3, 2026
  3. self-assigned this
    on Mar 4, 2026
  4. added
    S-has-mcve
    S-bug-has-test
    and removed
    needs-triage
    on Sep 7, 2026
  5. added 3 commits that reference this issue on Oct 28, 2026
    86b87f8
    b7ebeb5
    71aca69
  6. added a commit that references this issue on Oct 29, 2026
    1d814b8
  7. added a commit that references this issue on Oct 30, 2026
    1a0ee5e
  8. added a commit that references this issue on Nov 9, 2026
    5b20be7
  9. added a commit that references this issue on Nov 16, 2026
    846e841
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugI-ICES-bug-has-testS-has-mcveT-compilerWG-trait-system-refactor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions