ICE: `has_trivial_sizedness applied to unexpected type: FreshTy(0)`
Opened this issue · 2 comments
Code
#![feature(associated_const_equality)]
trait Project {
const SELF: [Self; 1];
}
fn take1(_: Project<SELF = {}>) {}A mutant of glacier2's fixed/123456.rs
Meta
rustc --version --verbose:
rustc 1.93.0-nightly (c90bcb957 2025-11-06)
binary: rustc
commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38
commit-date: 2025-11-06
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3
Error output
Command: rustc
error[E0601]: `main` function not found in crate `05`
--> 05.rs:7:35
|
7 | fn take1(_: Project<SELF = {}>) {}
| ^ consider adding a `main` function to `05.rs`
warning: trait objects without an explicit `dyn` are deprecated
--> 05.rs:7:13
|
7 | fn take1(_: Project<SELF = {}>) {}
| ^^^^^^^^^^^^^^^^^^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
|
7 | fn take1(_: dyn Project<SELF = {}>) {}
| +++
error[E0038]: the trait `Project` is not dyn compatible
--> 05.rs:7:13
|
7 | fn take1(_: Project<SELF = {}>) {}
| ^^^^^^^^^^^^^^^^^^ `Project` 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>
--> 05.rs:4:11
|
3 | trait Project {
| ------- this trait is not dyn compatible...
4 | const SELF: [Self; 1];
| ^^^^ ...because it contains this associated `const`
= help: consider moving `SELF` to another trait
error[E0277]: the size for values of type `Self` cannot be known at compilation time
--> 05.rs:4:17
|
4 | const SELF: [Self; 1];
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= note: slice and array elements must have `Sized` type
help: consider further restricting `Self`
|
3 | trait Project: Sized {
| +++++++
error[E0277]: the size for values of type `(dyn Project + 'static)` cannot be known at compilation time
--> 05.rs:7:13
|
7 | fn take1(_: Project<SELF = {}>) {}
| ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `(dyn Project + 'static)`
= help: unsized fn params are gated as an unstable feature
help: you can use `impl Trait` as the argument type
|
7 | fn take1(_: impl Project<SELF = {}>) {}
| ++++
help: function arguments must have a statically known size, borrowed types always have a known size
|
7 | fn take1(_: &dyn Project<SELF = {}>) {}
| ++++
error[E0308]: mismatched types
--> 05.rs:7:28
|
7 | fn take1(_: Project<SELF = {}>) {}
| ^^ expected `[FreshTy(0); 1]`, found `()`
|
= note: expected array `[FreshTy(0); 1]`
found unit type `()`
error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:1918:17: `has_trivial_sizedness` applied to unexpected type: FreshTy(0)
thread 'rustc' (5888757) panicked at compiler/rustc_middle/src/ty/sty.rs:1918:17:
Box<dyn Any>
Backtrace
thread 'rustc' (5888757) panicked at compiler/rustc_middle/src/ty/sty.rs:1918:17:
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_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
4: 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}, !>
5: rustc_middle::util::bug::bug_fmt
6: <rustc_middle::ty::Ty>::has_trivial_sizedness
7: rustc_trait_selection::traits::util::sizedness_fast_path
8: <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
9: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>
10: <rustc_trait_selection::traits::fulfill::FulfillmentContext<rustc_trait_selection::traits::FulfillmentError> as rustc_infer::traits::engine::TraitEngine<rustc_trait_selection::traits::FulfillmentError>>::try_evaluate_obligations
11: rustc_hir_typeck::typeck_with_inspect::{closure#0}
12: rustc_hir_typeck::typeck
[... omitted 1 frame ...]
13: rustc_hir_typeck::used_trait_imports
[... omitted 1 frame ...]
14: rustc_hir_analysis::check_unused::check_unused_traits
[... omitted 1 frame ...]
15: rustc_hir_analysis::check_crate
16: rustc_interface::passes::analysis
[... omitted 1 frame ...]
17: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
18: 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.
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 `/Users/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/20251106 ice 보고용/rustc-ice-2025-11-07T05_16_49-2721.txt` to your bug report
query stack during panic:
#0 [typeck] type-checking `take1::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `take1::{constant#0}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [analysis] running analysis passes on crate `05`
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted
Some errors have detailed explanations: E0038, E0277, E0308, E0601.
For more information about an error, try `rustc --explain E0038`.
Notes
-
ICE location:
compiler/rustc_middle/src/ty/sty.rs Line-1918
rust/compiler/rustc_middle/src/ty/sty.rs
Lines 1909 to 1919 in c90bcb9
-
Duplication Check
- I searched "has_trivial_sizedness" ICE issues, (Github issue page with query); and no ICE issue with that keyword.
@rustbot label +F-associated_const_equality
cargo-bisect-rustc --start=2022-01-01 --end=2025-11-07 --regress ice --preserve --script rustc -- 148625.rs
********************************************************************************
Regression in nightly-2022-02-03
********************************************************************************
fetching https://static.rust-lang.org/dist/2022-02-02/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-02-02: 40 B / 40 B [================================================================================================================================================] 100.00 % 855.45 KB/s converted 2022-02-02 to 2681f253bcdb31a274411d2be456e7c6a1c67d62
fetching https://static.rust-lang.org/dist/2022-02-03/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2022-02-03: 40 B / 40 B [================================================================================================================================================] 100.00 % 875.45 KB/s converted 2022-02-03 to 27f5d830eb11cd7bdc834d6f0d78120976f75443
looking for regression commit between 2022-02-02 and 2022-02-03
fetching (via remote github) commits from max(2681f253bcdb31a274411d2be456e7c6a1c67d62, 2022-01-31) to 27f5d830eb11cd7bdc834d6f0d78120976f75443
ending github query because we found starting sha: 2681f253bcdb31a274411d2be456e7c6a1c67d62
get_commits_between returning commits, len: 7
commit[0] 2022-02-01: Auto merge of #93442 - yaahc:Termination-abstraction, r=Mark-Simulacrum
commit[1] 2022-02-01: Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obk
commit[2] 2022-02-02: Auto merge of #93466 - cjgillot:query-dead, r=nagisa
commit[3] 2022-02-02: Auto merge of #93573 - matthiaskrgr:rollup-nrjmygz, r=matthiaskrgr
commit[4] 2022-02-02: Auto merge of #93154 - michaelwoerister:fix-generic-closure-and-generator-debuginfo, r=wesleywiser
commit[5] 2022-02-02: Auto merge of #93312 - pierwill:map-all-local-trait-impls, r=cjgillot
commit[6] 2022-02-02: Auto merge of #93594 - matthiaskrgr:rollup-lcvhpdv, r=matthiaskrgr
ERROR: no CI builds available between 2681f253bcdb31a274411d2be456e7c6a1c67d62 and 27f5d830eb11cd7bdc834d6f0d78120976f75443 within last 167 days
Thi is just another instance of #123140, #130411.
We're leaking a trait_object_dummy_self which is the underlying problem (see e.g., #123140 for details).
It happens to be the case that trait_object_dummy_self is defined to be Infer(FreshTy(0)). As a result, various later compiler stages will bug out when encountering this fake type and that can take on quite different panic messages & query stacks but the root issue is still the same.