rust-lang / rust-lang/rust

ICE: called `Option::unwrap()` on a `None` value

Open
#152,295 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-dyn-trait C-bug F-type_alias_impl_trait I-ICE S-bug-has-test S-has-mcve T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

#![feature(type_alias_impl_trait)]
type Tait = impl Sized;
trait Foo: Bar<Tait> {}
trait Bar<T> {
    fn bar(&self);
}
fn test_correct2(x: &dyn Foo) {
    x.bar();
}
fn main() {}
Release channel Result
Current Stable ICE
Current Nightly ICE
Current Nightly(-Z next-solver=globally) ICE
Meta

rustc --version --verbose:

rustc 1.95.0-nightly (db3e99bba 2026-02-04)
binary: rustc
commit-hash: db3e99bbab28c6ca778b13222becdea54533d908
commit-date: 2026-02-04
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0
Backtrace

thread 'rustc' panicked at /rustc-dev/db3e99bbab28c6ca778b13222becdea54533d908/compiler/rustc_trait_selection/src/traits/vtable.rs:363:77:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f522125af4b - <std[5b6453b30570829a]::backtrace::Backtrace>::create
   1:     0x7f522125ae95 - <std[5b6453b30570829a]::backtrace::Backtrace>::force_capture
   2:     0x7f522025d7b5 - std[5b6453b30570829a]::panicking::update_hook::<alloc[4b4e8be454901a39]::boxed::Box<rustc_driver_impl[70175e87f37eb535]::install_ice_hook::{closure#1}>>::{closure#0}
   3:     0x7f522126da42 - std[5b6453b30570829a]::panicking::panic_with_hook
   4:     0x7f522125047a - std[5b6453b30570829a]::panicking::panic_handler::{closure#0}
   5:     0x7f52212449b9 - std[5b6453b30570829a]::sys::backtrace::__rust_end_short_backtrace::<std[5b6453b30570829a]::panicking::panic_handler::{closure#0}, !>
   6:     0x7f5221251ead - __rustc[c8a7c5c4b6a2cdce]::rust_begin_unwind
   7:     0x7f521e4b610c - core[94716341d7c778ad]::panicking::panic_fmt
   8:     0x7f521da0ea82 - core[94716341d7c778ad]::panicking::panic
   9:     0x7f521e5727e9 - core[94716341d7c778ad]::option::unwrap_failed
  10:     0x7f52228830cb - rustc_trait_selection[b1d9eac621a96b17]::traits::vtable::first_method_vtable_slot
  11:     0x7f5222881d96 - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::first_method_vtable_slot::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>>
  12:     0x7f5222881d69 - <rustc_query_impl[5ce950bad06ac490]::query_impl::first_method_vtable_slot::make_query_vtable::{closure#1} as core[94716341d7c778ad]::ops::function::FnOnce<(rustc_middle[945890ed1064710a]::ty::context::TyCtxt, rustc_type_ir[e35c5fdc9bc4ed54]::predicate::TraitRef<rustc_middle[945890ed1064710a]::ty::context::TyCtxt>)>>::call_once
  13:     0x7f5222886947 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_query_system[cb5650c2b33f578c]::query::caches::DefaultCache<rustc_type_ir[e35c5fdc9bc4ed54]::predicate::TraitRef<rustc_middle[945890ed1064710a]::ty::context::TyCtxt>, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
  14:     0x7f522288668c - rustc_query_impl[5ce950bad06ac490]::query_impl::first_method_vtable_slot::get_query_non_incr::__rust_end_short_backtrace
  15:     0x7f5221f918cf - rustc_ty_utils[208ab547c572f55d]::instance::resolve_instance_raw
  16:     0x7f5221f8f33c - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::resolve_instance_raw::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 32usize]>>
  17:     0x7f5221f8e640 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_query_system[cb5650c2b33f578c]::query::caches::DefaultCache<rustc_middle[945890ed1064710a]::ty::PseudoCanonicalInput<(rustc_span[64ec0f452ae8c55c]::def_id::DefId, &rustc_middle[945890ed1064710a]::ty::list::RawList<(), rustc_middle[945890ed1064710a]::ty::generic_args::GenericArg>)>, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 32usize]>>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
  18:     0x7f5221f8e283 - rustc_query_impl[5ce950bad06ac490]::query_impl::resolve_instance_raw::get_query_non_incr::__rust_end_short_backtrace
  19:     0x7f5221d1257f - <rustc_middle[945890ed1064710a]::ty::instance::Instance>::try_resolve
  20:     0x7f5221d0e714 - <rustc_mir_transform[7868ec3e499e053b]::check_call_recursion::CheckCallRecursion as rustc_mir_transform[7868ec3e499e053b]::pass_manager::MirLint>::run_lint
  21:     0x7f522183fe79 - rustc_mir_transform[7868ec3e499e053b]::mir_built
  22:     0x7f522183fba3 - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::mir_built::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>>
  23:     0x7f5221b2535b - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_data_structures[1e615b1a93145c8c]::vec_cache::VecCache<rustc_span[64ec0f452ae8c55c]::def_id::LocalDefId, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 8usize]>, rustc_query_system[cb5650c2b33f578c]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: true }}>, false>
  24:     0x7f5221b24c59 - rustc_query_impl[5ce950bad06ac490]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7f5221d9efb0 - rustc_mir_build[92fa072902886eb8]::check_unsafety::check_unsafety
  26:     0x7f5221d9ed59 - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::check_unsafety::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>>
  27:     0x7f5221da67d6 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_data_structures[1e615b1a93145c8c]::vec_cache::VecCache<rustc_span[64ec0f452ae8c55c]::def_id::LocalDefId, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>, rustc_query_system[cb5650c2b33f578c]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
  28:     0x7f5221da654b - rustc_query_impl[5ce950bad06ac490]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7f5221da5708 - <rustc_middle[945890ed1064710a]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[391380b3dd77dca3]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  30:     0x7f5221da324a - rustc_interface[391380b3dd77dca3]::passes::analysis
  31:     0x7f5221da266b - rustc_query_impl[5ce950bad06ac490]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5ce950bad06ac490]::query_impl::analysis::make_query_vtable::{closure#1}::{closure#0}, rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>>
  32:     0x7f52229c15e6 - rustc_query_system[cb5650c2b33f578c]::query::plumbing::try_execute_query::<rustc_query_impl[5ce950bad06ac490]::SemiDynamicQueryDispatcher<rustc_query_system[cb5650c2b33f578c]::query::caches::SingleCache<rustc_middle[945890ed1064710a]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[5ce950bad06ac490]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}>, false>
  33:     0x7f52229c1348 - rustc_query_impl[5ce950bad06ac490]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f5222b31da7 - <rustc_interface[391380b3dd77dca3]::passes::create_and_enter_global_ctxt<core[94716341d7c778ad]::option::Option<rustc_interface[391380b3dd77dca3]::queries::Linker>, rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[94716341d7c778ad]::ops::function::FnOnce<(&rustc_session[79dda06290ce4e69]::session::Session, rustc_middle[945890ed1064710a]::ty::context::CurrentGcx, alloc[4b4e8be454901a39]::sync::Arc<rustc_data_structures[1e615b1a93145c8c]::jobserver::Proxy>, &std[5b6453b30570829a]::sync::once_lock::OnceLock<rustc_middle[945890ed1064710a]::ty::context::GlobalCtxt>, &rustc_data_structures[1e615b1a93145c8c]::sync::worker_local::WorkerLocal<rustc_middle[945890ed1064710a]::arena::Arena>, &rustc_data_structures[1e615b1a93145c8c]::sync::worker_local::WorkerLocal<rustc_hir[a9e131cadb307f85]::Arena>, rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  35:     0x7f52229e30be - rustc_interface[391380b3dd77dca3]::interface::run_compiler::<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}
  36:     0x7f5222a256fe - std[5b6453b30570829a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[391380b3dd77dca3]::util::run_in_thread_with_globals<rustc_interface[391380b3dd77dca3]::util::run_in_thread_pool_with_globals<rustc_interface[391380b3dd77dca3]::interface::run_compiler<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  37:     0x7f5222a25c20 - <std[5b6453b30570829a]::thread::lifecycle::spawn_unchecked<rustc_interface[391380b3dd77dca3]::util::run_in_thread_with_globals<rustc_interface[391380b3dd77dca3]::util::run_in_thread_pool_with_globals<rustc_interface[391380b3dd77dca3]::interface::run_compiler<(), rustc_driver_impl[70175e87f37eb535]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[94716341d7c778ad]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f5222a26aac - <std[5b6453b30570829a]::sys::thread::unix::Thread>::new::thread_start
  39:     0x7f521c5de609 - start_thread
                               at /build/glibc-B3wQXB/glibc-2.31/nptl/pthread_create.c:477:8
  40:     0x7f521c503353 - clone
                               at /build/glibc-B3wQXB/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
  41:                0x0 - <unknown>


rustc version: 1.95.0-nightly (db3e99bba 2026-02-04)
platform: x86_64-unknown-linux-gnu

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<'_, '_, Tait>>::bar`
#2 [mir_built] building MIR for `test_correct2`
#3 [check_unsafety] unsafety-checking `test_correct2`
#4 [analysis] running analysis passes on crate `bug`
end of query stack

@rustbot label +I-ICE +T-compiler +C-bug

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.

Research direction

Reproduce the ICE with the provided type_alias_impl_trait and trait-object example, then inspect compiler/rustc_trait_selection/src/traits/vtable.rs around first_method_vtable_slot. Trace the related resolve_instance_raw path shown in the backtrace and add a regression test for the example; done means compilation no longer panics on stable, nightly, or the listed next-solver mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.