[ICE]: assertion failed: Foo == U
Open
@TaKO8Ki is already working on this.
Since Feb 4, 2026.
C-bug
F-coerce_unsized
I-ICE
T-compiler
WG-trait-system-refactor
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
//@compile-flags: -Znext-solver=globally
use std::ops::CoerceUnsized;
struct Foo<T: ?Sized> {
a: T,
}
impl<T, U> CoerceUnsized<U> for Foo<T> {}
union U {
a: usize,
}
const C: U = Foo { a: 10 };
original:
use std::ops::CoerceUnsized;
struct Foo<T: ?Sized> {
a: T,
}
impl<T, U> CoerceUnsized<U> for Foo<T> {}
union U {
a: usize,
}
const C: U = Foo { a: 10 };
const _: [(); {
C;
0
}] = [];
fn main() {
|found: &String| Some(false);
4
}
Version information
rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8
Possibly related line of code:
https://github.com/rust-lang/rust/blob/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_const_eval/src/interpret/cast.rs#L472-L484
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally
Program output
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.dvo0cILjVdxS/rustc_testrunner_tmpdir_reporting.UkYxoYbwxxzg/mvce.rs:13:28
|
13 | const C: U = Foo { a: 10 };
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.dvo0cILjVdxS/rustc_testrunner_tmpdir_reporting.UkYxoYbwxxzg/mvce.rs`
error[E0658]: use of unstable library feature `coerce_unsized`
--> /tmp/icemaker_global_tempdir.dvo0cILjVdxS/rustc_testrunner_tmpdir_reporting.UkYxoYbwxxzg/mvce.rs:1:5
|
1 | use std::ops::CoerceUnsized;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
= help: add `#![feature(coerce_unsized)]` to the crate attributes to enable
= note: this compiler was built on 2026-01-18; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature `coerce_unsized`
--> /tmp/icemaker_global_tempdir.dvo0cILjVdxS/rustc_testrunner_tmpdir_reporting.UkYxoYbwxxzg/mvce.rs:7:12
|
7 | impl<T, U> CoerceUnsized<U> for Foo<T> {}
| ^^^^^^^^^^^^^^^^
|
= note: see issue #18598 <https://github.com/rust-lang/rust/issues/18598> for more information
= help: add `#![feature(coerce_unsized)]` to the crate attributes to enable
= note: this compiler was built on 2026-01-18; consider upgrading it if it is out of date
error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures
--> /tmp/icemaker_global_tempdir.dvo0cILjVdxS/rustc_testrunner_tmpdir_reporting.UkYxoYbwxxzg/mvce.rs:7:1
|
7 | impl<T, U> CoerceUnsized<U> for Foo<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' (1666937) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_const_eval/src/interpret/cast.rs:478:17:
assertion `left == right` failed
left: Foo
right: U
stack backtrace:
0: 0x7fee2a633fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
1: 0x7fee2ac0e2c8 - core[7477a31a1a34cc49]::fmt::write
2: 0x7fee2a64a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
3: 0x7fee2a60a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
4: 0x7fee2a627703 - std[287527946f71f0bc]::panicking::default_hook
5: 0x7fee295fbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fee2a6279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
7: 0x7fee2a60a108 - std[287527946f71f0bc]::panicking::panic_handler::{closure#0}
8: 0x7fee2a600dc9 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::panic_handler::{closure#0}, !>
9: 0x7fee2a60bbdd - __rustc[5ec7081ce87b032f]::rust_begin_unwind
10: 0x7fee2710cfbc - core[7477a31a1a34cc49]::panicking::panic_fmt
11: 0x7fee28f7d6d3 - core[7477a31a1a34cc49]::panicking::assert_failed_inner
12: 0x7fee294fd783 - core[7477a31a1a34cc49]::panicking::assert_failed::<rustc_middle[725063e074f29df]::ty::adt::AdtDef, rustc_middle[725063e074f29df]::ty::adt::AdtDef>
13: 0x7fee2c74423d - <rustc_const_eval[b948c5b36ae67fb9]::interpret::eval_context::InterpCx<rustc_const_eval[b948c5b36ae67fb9]::const_eval::machine::CompileTimeMachine>>::unsize_into::<rustc_const_eval[b948c5b36ae67fb9]::interpret::place::PlaceTy>.cold
14: 0x7fee2bd00904 - <rustc_const_eval[b948c5b36ae67fb9]::interpret::eval_context::InterpCx<rustc_const_eval[b948c5b36ae67fb9]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
15: 0x7fee2bcba0cd - rustc_const_eval[b948c5b36ae67fb9]::const_eval::eval_queries::eval_to_allocation_raw_provider
16: 0x7fee2bcb847e - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>
17: 0x7fee2bcb7ba5 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::DefaultCache<rustc_middle[725063e074f29df]::ty::PseudoCanonicalInput<rustc_middle[725063e074f29df]::mir::interpret::GlobalId>, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
18: 0x7fee2bcb7749 - rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
19: 0x7fee2bcb3504 - rustc_const_eval[b948c5b36ae67fb9]::const_eval::eval_queries::eval_to_const_value_raw_provider
20: 0x7fee2bcb3080 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>
21: 0x7fee2bcb1c8a - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::DefaultCache<rustc_middle[725063e074f29df]::ty::PseudoCanonicalInput<rustc_middle[725063e074f29df]::mir::interpret::GlobalId>, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 24usize]>>, false, true, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
22: 0x7fee2bcb17f3 - rustc_query_impl[f20b8284200e680a]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
23: 0x7fee2b7401b0 - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[1a80394817eddfdd]::check_crate::{closure#2}>::{closure#0}
24: 0x7fee2b73f7c4 - rustc_hir_analysis[1a80394817eddfdd]::check_crate
25: 0x7fee2ad493db - rustc_interface[5c48368f5debe80d]::passes::analysis
26: 0x7fee2ad49035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
27: 0x7fee2bda4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
28: 0x7fee2bda49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
29: 0x7fee2bf82c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
30: 0x7fee2bdf5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
31: 0x7fee2bd5aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32: 0x7fee2bd5a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33: 0x7fee2bd5c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
34: 0x7fee2569698b - <unknown>
35: 0x7fee2571a9cc - <unknown>
36: 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.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `C`
#1 [eval_to_const_value_raw] simplifying constant for the type system `C`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0377, E0601, E0658.
For more information about an error, try `rustc --explain E0377`.
@rustbot label +WG-trait-system-refactor
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.