[ICE]: `has_trivial_sizedness` applied to unexpected type: FreshTy(0)
Open
Nobody has claimed this yet.
C-bug
F-min_generic_const_args
I-ICE
T-compiler
WG-trait-system-refactor
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
This is a reduction of tests/ui/const-generics/associated-const-bindings/dyn-compat-self-const-projections-in-assoc-const-ty.rs which errors with the old solver but ICEs with the new solveer
auto-reduced (treereduce-rust):
//@compile-flags: -Znext-solver=globally
trait A {
type Ty;
const CT: Self::Ty;
}
fn main() {
let _: &dyn A<Ty = i32, CT = 0> = &();
}
original code
original:
// FIXME(mgca): Ideally this would compile -- at least if the user annotated the instantiated type
// of the assoc const (but we don't have the syntax for this (yet)). In any case, we
// should not leak `trait_object_dummy_self` (defined as `FreshTy(0)` under the hood)
// to the rest of the compiler and by extension the user via diagnostics.
//@ known-bug: unknown
#![feature(min_generic_const_args, unsized_const_params, generic_const_parameter_types)]
#![expect(incomplete_features)]
trait A {
type Ty: std::marker::ConstParamTy_;
#[type_const] const CT: Self::Ty;
}
impl A for () {
type Ty = i32;
#[type_const] const CT: i32 = 0;
}
fn main() {
// NOTE: As alluded to above, if we can't get the examples below to compile as written,
// we might want to allow the user to manually specify the instantiated type somehow.
// The hypothetical syntax for that *might* look sth. like
// * `dyn A<Ty = i32, CT = const -> i32 { 0 }>`
// * `dyn A<Ty = i32, CT: i32 = 0>`
let _: dyn A<Ty = i32, CT = 0>;
let _: &dyn A<Ty = i32, CT = 0> = &();
}
Version information
rustc 1.95.0-nightly (474276961 2026-01-26)
binary: rustc
commit-hash: 474276961f48b0d05f4ea260ba400096b027584e
commit-date: 2026-01-26
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/474276961f48b0d05f4ea260ba400096b027584e/compiler/rustc_middle/src/ty/sty.rs#L1942-L1954
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally
Program output
error[E0658]: associated const equality is incomplete
--> /tmp/icemaker_global_tempdir.TGsFqJ5aLR2p/rustc_testrunner_tmpdir_reporting.XHfzxY8f2x0j/mvce.rs:7:29
|
7 | let _: &dyn A<Ty = i32, CT = 0> = &();
| ^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
= note: this compiler was built on 2026-01-26; consider upgrading it if it is out of date
error[E0038]: the trait `A` is not dyn compatible
--> /tmp/icemaker_global_tempdir.TGsFqJ5aLR2p/rustc_testrunner_tmpdir_reporting.XHfzxY8f2x0j/mvce.rs:7:17
|
7 | let _: &dyn A<Ty = i32, CT = 0> = &();
| ^^^^^^^^^^^^^^^^^^^ `A` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> /tmp/icemaker_global_tempdir.TGsFqJ5aLR2p/rustc_testrunner_tmpdir_reporting.XHfzxY8f2x0j/mvce.rs:3:11
|
1 | trait A {
| - this trait is not dyn compatible...
2 | type Ty;
3 | const CT: Self::Ty;
| ^^ ...because it contains associated const `CT`
= help: consider moving `CT` to another trait
error: internal compiler error: /rustc-dev/474276961f48b0d05f4ea260ba400096b027584e/compiler/rustc_middle/src/ty/sty.rs:1948:17: `has_trivial_sizedness` applied to unexpected type: FreshTy(0)
thread 'rustc' (4068086) panicked at /rustc-dev/474276961f48b0d05f4ea260ba400096b027584e/compiler/rustc_middle/src/ty/sty.rs:1948:17:
Box<dyn Any>
stack backtrace:
0: 0x7fe996e39a03 - <<std[8cc15e19e2a5acfa]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ea2bd7cd219b3eb9]::fmt::Display>::fmt
1: 0x7fe99740e61c - core[ea2bd7cd219b3eb9]::fmt::write
2: 0x7fe996e501a6 - <std[8cc15e19e2a5acfa]::sys::stdio::unix::Stderr as std[8cc15e19e2a5acfa]::io::Write>::write_fmt
3: 0x7fe996e0f898 - std[8cc15e19e2a5acfa]::panicking::default_hook::{closure#0}
4: 0x7fe996e2d033 - std[8cc15e19e2a5acfa]::panicking::default_hook
5: 0x7fe995e18d2d - std[8cc15e19e2a5acfa]::panicking::update_hook::<alloc[d48b8b032ee4278d]::boxed::Box<rustc_driver_impl[b96920060a9f9ce8]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fe996e2d312 - std[8cc15e19e2a5acfa]::panicking::panic_with_hook
7: 0x7fe995e4d2c1 - std[8cc15e19e2a5acfa]::panicking::begin_panic::<rustc_errors[229f37ed4a6a6271]::ExplicitBug>::{closure#0}
8: 0x7fe995e45ea6 - std[8cc15e19e2a5acfa]::sys::backtrace::__rust_end_short_backtrace::<std[8cc15e19e2a5acfa]::panicking::begin_panic<rustc_errors[229f37ed4a6a6271]::ExplicitBug>::{closure#0}, !>
9: 0x7fe995e43aa9 - std[8cc15e19e2a5acfa]::panicking::begin_panic::<rustc_errors[229f37ed4a6a6271]::ExplicitBug>
10: 0x7fe995e58421 - <rustc_errors[229f37ed4a6a6271]::diagnostic::BugAbort as rustc_errors[229f37ed4a6a6271]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7fe996405cd9 - rustc_middle[8d85aae3cf006bd8]::util::bug::opt_span_bug_fmt::<rustc_span[94ae33b9311191df]::span_encoding::Span>::{closure#0}
12: 0x7fe996405e62 - rustc_middle[8d85aae3cf006bd8]::ty::context::tls::with_opt::<rustc_middle[8d85aae3cf006bd8]::util::bug::opt_span_bug_fmt<rustc_span[94ae33b9311191df]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7fe9963f6f5b - rustc_middle[8d85aae3cf006bd8]::ty::context::tls::with_context_opt::<rustc_middle[8d85aae3cf006bd8]::ty::context::tls::with_opt<rustc_middle[8d85aae3cf006bd8]::util::bug::opt_span_bug_fmt<rustc_span[94ae33b9311191df]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7fe993abe9a4 - rustc_middle[8d85aae3cf006bd8]::util::bug::bug_fmt
15: 0x7fe997c1e5a2 - <rustc_middle[8d85aae3cf006bd8]::ty::Ty>::has_trivial_sizedness
16: 0x7fe997f2b6a4 - <rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate as rustc_next_trait_solver[8c43bb7854d9f213]::delegate::SolverDelegate>::compute_goal_fast_path
17: 0x7fe997f248ea - <rustc_next_trait_solver[8c43bb7854d9f213]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate, rustc_middle[8d85aae3cf006bd8]::ty::context::TyCtxt>>::try_evaluate_added_goals
18: 0x7fe997f44571 - <rustc_next_trait_solver[8c43bb7854d9f213]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate, rustc_middle[8d85aae3cf006bd8]::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response
19: 0x7fe998278c2b - <rustc_next_trait_solver[8c43bb7854d9f213]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate> as rustc_type_ir[f9818e68c953de5]::search_graph::Delegate>::compute_goal::{closure#0}
20: 0x7fe998277c0d - <rustc_type_ir[f9818e68c953de5]::search_graph::SearchGraph<rustc_next_trait_solver[8c43bb7854d9f213]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate>, rustc_middle[8d85aae3cf006bd8]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}::{closure#2}
21: 0x7fe997f34264 - <rustc_next_trait_solver[8c43bb7854d9f213]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[326fa56f4f3ccdfa]::solve::delegate::SolverDelegate, rustc_middle[8d85aae3cf006bd8]::ty::context::TyCtxt>>::evaluate_goal_raw
22: 0x7fe997f30b54 - <rustc_trait_selection[326fa56f4f3ccdfa]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[326fa56f4f3ccdfa]::traits::FulfillmentError> as rustc_infer[f0ecf96d753785e1]::traits::engine::TraitEngine<rustc_trait_selection[326fa56f4f3ccdfa]::traits::FulfillmentError>>::try_evaluate_obligations
23: 0x7fe9978509d9 - <rustc_hir_typeck[82597958bed5eb62]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: 0x7fe99814e789 - rustc_hir_typeck[82597958bed5eb62]::typeck_with_inspect::{closure#0}
25: 0x7fe99814a5ba - rustc_query_impl[f52eeba12e8a164a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f52eeba12e8a164a]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 8usize]>>
26: 0x7fe99756992a - rustc_query_system[54a10b0b4f070675]::query::plumbing::try_execute_query::<rustc_query_impl[f52eeba12e8a164a]::DynamicConfig<rustc_data_structures[80b3ed06db703e49]::vec_cache::VecCache<rustc_span[94ae33b9311191df]::def_id::LocalDefId, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[54a10b0b4f070675]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f52eeba12e8a164a]::plumbing::QueryCtxt, false>
27: 0x7fe997569209 - rustc_query_impl[f52eeba12e8a164a]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
28: 0x7fe99756a555 - rustc_query_impl[f52eeba12e8a164a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f52eeba12e8a164a]::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 8usize]>>
29: 0x7fe99756992a - rustc_query_system[54a10b0b4f070675]::query::plumbing::try_execute_query::<rustc_query_impl[f52eeba12e8a164a]::DynamicConfig<rustc_data_structures[80b3ed06db703e49]::vec_cache::VecCache<rustc_span[94ae33b9311191df]::def_id::LocalDefId, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[54a10b0b4f070675]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f52eeba12e8a164a]::plumbing::QueryCtxt, false>
30: 0x7fe9975692c9 - rustc_query_impl[f52eeba12e8a164a]::query_impl::used_trait_imports::get_query_non_incr::__rust_end_short_backtrace
31: 0x7fe99756a66f - rustc_hir_analysis[a3c3123a8725cc24]::check_unused::check_unused_traits
32: 0x7fe99756a587 - rustc_query_impl[f52eeba12e8a164a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f52eeba12e8a164a]::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 0usize]>>
33: 0x7fe9985d3d91 - rustc_query_system[54a10b0b4f070675]::query::plumbing::try_execute_query::<rustc_query_impl[f52eeba12e8a164a]::DynamicConfig<rustc_query_system[54a10b0b4f070675]::query::caches::SingleCache<rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f52eeba12e8a164a]::plumbing::QueryCtxt, false>
34: 0x7fe9985d39ce - rustc_query_impl[f52eeba12e8a164a]::query_impl::check_unused_traits::get_query_non_incr::__rust_end_short_backtrace
35: 0x7fe9979c9863 - rustc_hir_analysis[a3c3123a8725cc24]::check_crate
36: 0x7fe9975633a7 - rustc_interface[4728fac6abb1a1aa]::passes::analysis
37: 0x7fe997563009 - rustc_query_impl[f52eeba12e8a164a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f52eeba12e8a164a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 0usize]>>
38: 0x7fe9985d3d91 - rustc_query_system[54a10b0b4f070675]::query::plumbing::try_execute_query::<rustc_query_impl[f52eeba12e8a164a]::DynamicConfig<rustc_query_system[54a10b0b4f070675]::query::caches::SingleCache<rustc_middle[8d85aae3cf006bd8]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f52eeba12e8a164a]::plumbing::QueryCtxt, false>
39: 0x7fe9985d3b7c - rustc_query_impl[f52eeba12e8a164a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
40: 0x7fe9987b31d1 - <rustc_interface[4728fac6abb1a1aa]::passes::create_and_enter_global_ctxt<core[ea2bd7cd219b3eb9]::option::Option<rustc_interface[4728fac6abb1a1aa]::queries::Linker>, rustc_driver_impl[b96920060a9f9ce8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[ea2bd7cd219b3eb9]::ops::function::FnOnce<(&rustc_session[a8d494af7dba883f]::session::Session, rustc_middle[8d85aae3cf006bd8]::ty::context::CurrentGcx, alloc[d48b8b032ee4278d]::sync::Arc<rustc_data_structures[80b3ed06db703e49]::jobserver::Proxy>, &std[8cc15e19e2a5acfa]::sync::once_lock::OnceLock<rustc_middle[8d85aae3cf006bd8]::ty::context::GlobalCtxt>, &rustc_data_structures[80b3ed06db703e49]::sync::worker_local::WorkerLocal<rustc_middle[8d85aae3cf006bd8]::arena::Arena>, &rustc_data_structures[80b3ed06db703e49]::sync::worker_local::WorkerLocal<rustc_hir[f8bf578c86c342b0]::Arena>, rustc_driver_impl[b96920060a9f9ce8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
41: 0x7fe9985e73eb - rustc_interface[4728fac6abb1a1aa]::interface::run_compiler::<(), rustc_driver_impl[b96920060a9f9ce8]::run_compiler::{closure#0}>::{closure#1}
42: 0x7fe998636dbe - std[8cc15e19e2a5acfa]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4728fac6abb1a1aa]::util::run_in_thread_with_globals<rustc_interface[4728fac6abb1a1aa]::util::run_in_thread_pool_with_globals<rustc_interface[4728fac6abb1a1aa]::interface::run_compiler<(), rustc_driver_impl[b96920060a9f9ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
43: 0x7fe9986372e0 - <std[8cc15e19e2a5acfa]::thread::lifecycle::spawn_unchecked<rustc_interface[4728fac6abb1a1aa]::util::run_in_thread_with_globals<rustc_interface[4728fac6abb1a1aa]::util::run_in_thread_pool_with_globals<rustc_interface[4728fac6abb1a1aa]::interface::run_compiler<(), rustc_driver_impl[b96920060a9f9ce8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ea2bd7cd219b3eb9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
44: 0x7fe99863816c - <std[8cc15e19e2a5acfa]::sys::thread::unix::Thread>::new::thread_start
45: 0x7fe991e9698b - <unknown>
46: 0x7fe991f1a9cc - <unknown>
47: 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: rustc 1.95.0-nightly (474276961 2026-01-26) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir
query stack during panic:
#0 [typeck] type-checking `main::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `main::{constant#0}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0038, E0658.
For more information about an error, try `rustc --explain E0038`.
@rustbot label +F-min_generic_const_args +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.