rust-lang / rust-lang/rust

[ICE]: monomorphization failure

Open
#158,756 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-codegen A-monomorphization A-trait-system C-bug fixed-by-next-solver I-ICE I-prioritize regression-from-stable-to-stable T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
// no idea how to minimize this one; it doesn't happen when i start paring things down, but i have
// committed it in a branch in case you want to see the horrors
Meta

Crashes similarly in all of the below:
rustc --version --verbose:

rustc 1.98.0-nightly (c397dae80 2026-07-02)
binary: rustc
commit-hash: c397dae808f70caebab1fc4e11b3edf7e59f58c7
commit-date: 2026-07-02
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.8

rustc 1.97.0-beta.6 (b2282dd56 2026-07-01)
binary: rustc
commit-hash: b2282dd5646a57d570fc86fbe8df0e8826665ef6
commit-date: 2026-07-01
host: x86_64-unknown-linux-gnu
release: 1.97.0-beta.6
LLVM version: 22.1.6

rustc 1.96.1 (31fca3adb 2026-06-26)
binary: rustc
commit-hash: 31fca3adb283cc9dfd56b49cdee9a96eb9c96ffd
commit-date: 2026-06-26
host: x86_64-unknown-linux-gnu
release: 1.96.1
LLVM version: 22.1.2

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0
Error output

from stable:

query stack during panic:
#0 [items_of_instance] collecting items used by `_::_::<impl at examples/schema.rs:15:35: 15:42>::register::{closure#0}`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `bilrost` (example "schema")

Caused by:
  process didn't exit successfully: `/home/widders/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name schema --edition=2021 examples/schema.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=185 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="arrayvec"' --cfg 'feature="auto-optimize"' --cfg 'feature="auto-self-copy-optimization"' --cfg 'feature="auto-unroll-varint-encoding"' --cfg 'feature="bstr"' --cfg 'feature="bytestring"' --cfg 'feature="chrono"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="detailed-errors"' --cfg 'feature="extended-diagnostics"' --cfg 'feature="full-test-suite"' --cfg 'feature="hashbrown"' --cfg 'feature="smallvec"' --cfg 'feature="smol_str"' --cfg 'feature="std"' --cfg 'feature="thin-vec"' --cfg 'feature="third-party-type-support"' --cfg 'feature="threadsafe-schema"' --cfg 'feature="time"' --cfg 'feature="tinyvec"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("arrayvec", "auto-optimize", "auto-self-copy-optimization", "auto-unroll-varint-encoding", "bstr", "bytestring", "chrono", "default", "derive", "detailed-errors", "extended-diagnostics", "forbid-unsafe", "full-test-suite", "hashbrown", "no-recursion-limit", "pprof", "prefer-no-self-copy-optimization", "prefer-no-unroll-varint-encoding", "self-copy-optimization", "smallvec", "smol_str", "std", "test-smolstr-force-noncontiguous", "test-suite-extra", "thin-vec", "third-party-type-support", "threadsafe-schema", "time", "tinyvec", "unroll-varint-encoding"))' -C metadata=34e72ac2315b8ee5 -C extra-filename=-8d74cb51b72d2517 --out-dir /home/widders/repos/bilrost/target/debug/examples -C incremental=/home/widders/repos/bilrost/target/debug/incremental -L dependency=/home/widders/repos/bilrost/target/debug/deps --extern arbitrary=/home/widders/repos/bilrost/target/debug/deps/libarbitrary-0728679b9e5fed63.rlib --extern arrayvec=/home/widders/repos/bilrost/target/debug/deps/libarrayvec-43fb47e4eb494826.rlib --extern bilrost=/home/widders/repos/bilrost/target/debug/deps/libbilrost-bf6a6f201ad1d6ad.rlib --extern bilrost=/home/widders/repos/bilrost/target/debug/deps/libbilrost-bf6a6f201ad1d6ad.rlib --extern bilrost_derive=/home/widders/repos/bilrost/target/debug/deps/libbilrost_derive-49c546cfd470378f.so --extern bilrost_types=/home/widders/repos/bilrost/target/debug/deps/libbilrost_types-9d0cd75059bc5925.rlib --extern bstr=/home/widders/repos/bilrost/target/debug/deps/libbstr-6c79ec6770561b68.rlib --extern bytes=/home/widders/repos/bilrost/target/debug/deps/libbytes-89660b0376fecedf.rlib --extern bytestring=/home/widders/repos/bilrost/target/debug/deps/libbytestring-d5491aa098aff8c8.rlib --extern chrono=/home/widders/repos/bilrost/target/debug/deps/libchrono-15470d385670c818.rlib --extern const_panic=/home/widders/repos/bilrost/target/debug/deps/libconst_panic-a84a675caa466021.rlib --extern criterion=/home/widders/repos/bilrost/target/debug/deps/libcriterion-95d5562a18b272eb.rlib --extern hashbrown=/home/widders/repos/bilrost/target/debug/deps/libhashbrown-5fe99400d436e3d9.rlib --extern itertools=/home/widders/repos/bilrost/target/debug/deps/libitertools-e667890de3b201ca.rlib --extern proptest=/home/widders/repos/bilrost/target/debug/deps/libproptest-ba16e32df9e695e4.rlib --extern rand=/home/widders/repos/bilrost/target/debug/deps/librand-b94da0b99e561c86.rlib --extern smallvec=/home/widders/repos/bilrost/target/debug/deps/libsmallvec-0768e0b6ef61c4d6.rlib --extern smol_str=/home/widders/repos/bilrost/target/debug/deps/libsmol_str-b563041025dd90b3.rlib --extern spin=/home/widders/repos/bilrost/target/debug/deps/libspin-9c58c3f0349ea4df.rlib --extern static_assertions=/home/widders/repos/bilrost/target/debug/deps/libstatic_assertions-b762000ac734cfdb.rlib --extern thin_vec=/home/widders/repos/bilrost/target/debug/deps/libthin_vec-fa529e225a04fbba.rlib --extern time=/home/widders/repos/bilrost/target/debug/deps/libtime-bda0b5b6beb993f2.rlib --extern tinyvec=/home/widders/repos/bilrost/target/debug/deps/libtinyvec-0590a625239ec7c9.rlib --extern yoke=/home/widders/repos/bilrost/target/debug/deps/libyoke-15ebf107e3aab358.rlib --cfg rustc_1_66 --cfg rustc_1_82 --check-cfg 'cfg(rustc_1_66)' --check-cfg 'cfg(rustc_1_82)'` (exit status: 101)
Backtrace

thread 'rustc' (521520) panicked at /rustc-dev/31fca3adb283cc9dfd56b49cdee9a96eb9c96ffd/compiler/rustc_middle/src/ty/instance.rs:568:21:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: <rustc_errors::DiagCtxtHandle>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_middle::ty::instance::Instance>::expect_resolve
   8: <rustc_monomorphize::collector::MirUsedCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
   9: rustc_monomorphize::collector::items_of_instance
      [... omitted 1 frame ...]
  10: rustc_monomorphize::collector::collect_items_rec
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}
  15: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 1 frame ...]
  16: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  17: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  18: <rustc_interface::queries::Linker>::codegen_and_build_linker
  19: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 with the reported failure in examples/schema.rs at 15:35 and reproduce the build using the stable, beta, or nightly compiler versions listed. The issue provides no code or minimal reproducer, so first reduce the committed branch to a verifiable example while preserving the monomorphization panic and query stack. Done means a reproducible case and a compiler fix or a clearly isolated cause.

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
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.