Repository navigation
[ICE]: monomorphization failure #158756
Copy link
Copy link
Open
Labels
A-codegenArea: Code generationArea: Code generationA-monomorphizationArea: MonomorphizationArea: MonomorphizationA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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 horrorsMeta
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-monomorphizationArea: MonomorphizationArea: MonomorphizationA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
saethlin commentedon Jul 4, 2026
mumbleskates commentedon Jul 4, 2026
saethlin commentedon Jul 5, 2026
saethlin commentedon Jul 6, 2026
zachs18 commentedon Jul 6, 2026
The ICE seems to not happen under
-Znext-solver=globally(RUSTFLAGS="-Znext-solver=globally cargo +nightly -Zscript ./bilrost.rsdoesn't ICE for https://github.com/saethlin/bilrost/blob/2526a1e0edcb481a55e8ba1ca48eea0965bca3e5/bilrost.rs)pitust commentedon Jul 6, 2026
2 remaining items
theemathas commentedon Jul 7, 2026
@lcnr What the caching is happening here? My guess is that it looks related to #t-types/trait-system-refactor > The old solver don't record required depth on cache
mumbleskates commentedon Jul 7, 2026
could these functions be aliasing somehow? like it's storing them under colliding keys and only stores and finds one when both are present in a given compilation?
matthiaskrgr commentedon Jul 8, 2026
this compiled with
nightly-2019-12-11but ICEs withnightly-2019-12-12maybe #66821?
mumbleskates commentedon Jul 9, 2026
This patch fixes the crash in current
main:re: #132279
mumbleskates commentedon Jul 9, 2026
in fact, going by my testing (as far as i can tell, i might be holding the rustc builder subtly wrong) each of the following also fix it:edit: sorry, there was build caching that
CARGO_INCREMENTAL=0was not taking care of in trying to test this. i've rerun against clean caches:this fixes the crash:
...and this does not fix it:
Details
mumbleskates commentedon Jul 11, 2026
i poked around a little bit and the above patch also fixes the crash in #146965
edit: and #146813
possible minimal fix for #146965, #146813, and #158756
Auto merge of #159209 - mumbleskates:trait-selection-experiment, r=<try>