ICE when computing the size of a specialized associated trait type #51892
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-specialization
Area: Trait impl specialization
C-bug
Category: This is a bug.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
F-specialization
`#![feature(specialization)]`
glacier
ICE tracked in rust-lang/glacier.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
requires-nightly
This issue requires a nightly compiler in some way.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code creates a trait (creatively named
Trait
) that has an associated type (creatively namedType
). An default implementation of this trait is given for all types, withType = [u8; 1]
. Specializing the trait (for*const T
, for example) works, except that doingsize_of::<<T as Trait>::Type>()
causes an ICE.(Playground link)
Expected behavior: I believe this code should compile just fine, with
*const T
'sTrait::Type
being equivalent to toT
'sTrait::Type
.Actual behavior: ICE:
error: internal compiler error: librustc/ty/subst.rs:479: Type parameter
T/#0(T/0) out of range when substituting (root type=Some(fn() -> usize {std::mem::size_of::<<T as Trait>::Type>})) substs=[]
Rust version:
rustc --version --verbose:
Backtrace:
The text was updated successfully, but these errors were encountered: