rust-lang / rust-lang/rust

[ICE]: `virtual dispatches have no instance MIR`

Open
#158,411 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

-Clink-dead-code C-bug F-checked_type_aliases I-ICE T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
//@ compiler-flags: -Clink-dead-code
#![feature(lazy_type_alias)]
impl Trait for Struct {}
pub trait Trait {
  fn a(&self) {}
}
pub type Struct = Trait;

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.98.0-nightly (973ad0d0a 2026-06-25)
binary: rustc
commit-hash: 973ad0d0ab149bde2e96422833c1265c7a5be217
commit-date: 2026-06-25
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.7
Error output
<output>
Backtrace

error: internal compiler error: /rustc-dev/973ad0d0ab149bde2e96422833c1265c7a5be217/compiler/rustc_middle/src/ty/mod.rs:1807:46: virtual dispatches have no instance MIR


thread 'rustc' (4179870) panicked at /rustc-dev/973ad0d0ab149bde2e96422833c1265c7a5be217/compiler/rustc_middle/src/ty/mod.rs:1807:46:
Box<dyn Any>
stack backtrace:
   0:     0x7fdacf07f7c9 - <<std[93d08488200afbe9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f7e291d2543430ab]::fmt::Display>::fmt
   1:     0x7fdacf60ed5e - core[f7e291d2543430ab]::fmt::write
   2:     0x7fdacf095e36 - <std[93d08488200afbe9]::sys::stdio::unix::Stderr as std[93d08488200afbe9]::io::Write>::write_fmt
   3:     0x7fdacf054a8e - std[93d08488200afbe9]::panicking::default_hook::{closure#0}
   4:     0x7fdacf0724b3 - std[93d08488200afbe9]::panicking::default_hook
   5:     0x7fdace0b9da1 - std[93d08488200afbe9]::panicking::update_hook::<alloc[53d916e428402608]::boxed::Box<rustc_driver_impl[979a081fdb5de70a]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fdacf072792 - std[93d08488200afbe9]::panicking::panic_with_hook
   7:     0x7fdace0e7511 - std[93d08488200afbe9]::panicking::begin_panic::<rustc_errors[264333f2c4fc38ce]::ExplicitBug>::{closure#0}
   8:     0x7fdace0e0506 - std[93d08488200afbe9]::sys::backtrace::__rust_end_short_backtrace::<std[93d08488200afbe9]::panicking::begin_panic<rustc_errors[264333f2c4fc38ce]::ExplicitBug>::{closure#0}, !>
   9:     0x7fdace0de217 - std[93d08488200afbe9]::panicking::begin_panic::<rustc_errors[264333f2c4fc38ce]::ExplicitBug>
  10:     0x7fdace0f26a1 - <rustc_errors[264333f2c4fc38ce]::diagnostic::BugAbort as rustc_errors[264333f2c4fc38ce]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fdace641859 - rustc_middle[bcc3288a6814d0a4]::util::bug::opt_span_bug_fmt::<rustc_span[35a08c5840550152]::span_encoding::Span>::{closure#0}
  12:     0x7fdace6419c2 - rustc_middle[bcc3288a6814d0a4]::ty::context::tls::with_opt::<rustc_middle[bcc3288a6814d0a4]::util::bug::opt_span_bug_fmt<rustc_span[35a08c5840550152]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fdace62e01b - rustc_middle[bcc3288a6814d0a4]::ty::context::tls::with_context_opt::<rustc_middle[bcc3288a6814d0a4]::ty::context::tls::with_opt<rustc_middle[bcc3288a6814d0a4]::util::bug::opt_span_bug_fmt<rustc_span[35a08c5840550152]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fdacb8f1984 - rustc_middle[bcc3288a6814d0a4]::util::bug::bug_fmt
  15:     0x7fdacfff9d9d - <rustc_middle[bcc3288a6814d0a4]::ty::context::TyCtxt>::instance_mir
  16:     0x7fdacfffcb4b - rustc_monomorphize[e5a33d18fbf7dfd7]::collector::items_of_instance
  17:     0x7fdacfffcad1 - rustc_query_impl[17a4b120598da42c]::query_impl::items_of_instance::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fdad0015230 - rustc_query_impl[17a4b120598da42c]::execution::try_execute_query::<rustc_middle[bcc3288a6814d0a4]::query::caches::DefaultCache<(rustc_middle[bcc3288a6814d0a4]::ty::instance::Instance, rustc_middle[bcc3288a6814d0a4]::mono::CollectionMode), rustc_middle[bcc3288a6814d0a4]::query::erase::ErasedData<[u8; 32usize]>>, false>
  19:     0x7fdad0014e9b - rustc_query_impl[17a4b120598da42c]::query_impl::items_of_instance::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fdad0013854 - rustc_monomorphize[e5a33d18fbf7dfd7]::collector::collect_items_rec::{closure#0}
  21:     0x7fdad0a5f13a - rustc_monomorphize[e5a33d18fbf7dfd7]::collector::collect_items_rec
  22:     0x7fdacfdb92a1 - rustc_monomorphize[e5a33d18fbf7dfd7]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  23:     0x7fdad0264f4f - rustc_monomorphize[e5a33d18fbf7dfd7]::partitioning::collect_and_partition_mono_items
  24:     0x7fdad079dc68 - rustc_query_impl[17a4b120598da42c]::query_impl::collect_and_partition_mono_items::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7fdad079d5c1 - rustc_query_impl[17a4b120598da42c]::execution::try_execute_query::<rustc_middle[bcc3288a6814d0a4]::query::caches::SingleCache<rustc_middle[bcc3288a6814d0a4]::query::erase::ErasedData<[u8; 24usize]>>, false>
  26:     0x7fdad079d27c - rustc_query_impl[17a4b120598da42c]::query_impl::collect_and_partition_mono_items::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7fdacfeabca4 - rustc_codegen_ssa[147effa7f152b327]::back::symbol_export::exported_generic_symbols_provider_local
  28:     0x7fdad0425468 - rustc_query_impl[17a4b120598da42c]::query_impl::exported_generic_symbols::invoke_provider_fn::__rust_begin_short_backtrace
  29:     0x7fdad042376d - rustc_query_impl[17a4b120598da42c]::execution::try_execute_query::<rustc_data_structures[4869b7949a113a92]::vec_cache::VecCache<rustc_span[35a08c5840550152]::def_id::CrateNum, rustc_middle[bcc3288a6814d0a4]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[bcc3288a6814d0a4]::dep_graph::graph::DepNodeIndex>, false>
  30:     0x7fdad0423283 - rustc_query_impl[17a4b120598da42c]::query_impl::exported_generic_symbols::execute_query_non_incr::__rust_end_short_backtrace
  31:     0x7fdacfe7d867 - <rustc_metadata[62f2524ca2ba8bcb]::rmeta::encoder::EncodeContext>::encode_crate_root
  32:     0x7fdad05157d5 - rustc_metadata[62f2524ca2ba8bcb]::rmeta::encoder::encode_metadata::{closure#3}
  33:     0x7fdad0512fa1 - rustc_metadata[62f2524ca2ba8bcb]::rmeta::encoder::encode_metadata
  34:     0x7fdad051d105 - rustc_metadata[62f2524ca2ba8bcb]::fs::encode_and_write_metadata
  35:     0x7fdad0762c3b - <rustc_interface[71cd11911924984b]::queries::Linker>::codegen_and_build_linker
  36:     0x7fdad075d9bd - rustc_interface[71cd11911924984b]::interface::run_compiler::<(), rustc_driver_impl[979a081fdb5de70a]::run_compiler::{closure#0}>::{closure#1}
  37:     0x7fdad078dc7a - std[93d08488200afbe9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[71cd11911924984b]::util::run_in_thread_with_globals<rustc_interface[71cd11911924984b]::util::run_in_thread_pool_with_globals<rustc_interface[71cd11911924984b]::interface::run_compiler<(), rustc_driver_impl[979a081fdb5de70a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x7fdad078da2d - <std[93d08488200afbe9]::thread::lifecycle::spawn_unchecked<rustc_interface[71cd11911924984b]::util::run_in_thread_with_globals<rustc_interface[71cd11911924984b]::util::run_in_thread_pool_with_globals<rustc_interface[71cd11911924984b]::interface::run_compiler<(), rustc_driver_impl[979a081fdb5de70a]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f7e291d2543430ab]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7fdad0783f10 - <std[93d08488200afbe9]::sys::thread::unix::Thread>::new::thread_start
  40:     0x7fdaca2981b9 - <unknown>
  41:     0x7fdaca31d21c - <unknown>
  42:                0x0 - <unknown>

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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-06-25T16_55_05-4179868.txt` to your bug report

note: rustc 1.98.0-nightly (973ad0d0a 2026-06-25) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C link-dead-code

query stack during panic:
#0 [items_of_instance] collecting items used by `<dyn Trait as Trait>::a - virtual#3`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
#2 [exported_generic_symbols] collecting exported generic symbols for crate `0`
end of query stack
error: aborting due to 1 previous error; 2 warnings emitted

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

Start by reproducing the minimal example with the nightly compiler and -Clink-dead-code. Read compiler/rustc_middle/src/ty/mod.rs around instance_mir and follow the rustc_monomorphize collector entries shown in the query stack. Done means this example no longer triggers the internal compiler error and the relevant compiler tests cover the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.