-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler crash with extensive use of const generics #126078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
A-monomorphization
Area: Monomorphization
C-bug
Category: This is a bug.
E-needs-mcve
Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
F-adt_const_params
`#![feature(adt_const_params)]`
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
requires-incomplete-features
This issue requires the use of incomplete features.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Sorry but this is an incomplete feature, so this is a known problem! If you can extract a minimized version, that would be great! |
A smaller example with no dependencies other than stdlib I'm still messing around with it, now it's down to 1.5kb |
#![feature(generic_const_exprs)]
trait Tensor {
const S: usize;
}
struct GenericTensor<const S: usize>;
impl<const S: usize> Tensor for GenericTensor<S> {
const S: usize = S;
}
impl<const S: usize> GenericTensor<S> {
fn forward(&self) {
[View(GenericTensor::<S>), View(GenericTensor).into()];
}
}
pub fn test_bcast_elem_add() {
(GenericTensor::<0>).forward()
}
struct View<T>(T);
impl<Tn> From<View<GenericTensor<{ Tn::S }>>> for View<Tn>
where
Tn: Tensor,
{
fn from(_: View<GenericTensor<{ Tn::S }>>) -> Self {
loop {}
}
} |
neat! |
Minimized further: #![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Array {
const SIZE: usize;
}
impl<const N: usize> Array for [i32; N] {
const SIZE: usize = N;
}
// Note: Overlapping impls not detected by compiler
trait Reflexive<T> {
fn reflexive() {}
}
impl<T> Reflexive<T> for T {}
impl<A: Array> Reflexive<[i32; A::SIZE]> for A {}
fn do_reflexive<const N: usize>() {
<[i32; N]>::reflexive();
}
// Note: Load-bearing `pub`. Removing the pub stops the ICE.
pub fn what() {
do_reflexive::<0>()
} Compiler error
|
Looks like a duplicate of #119692 |
Closing as duplicate then. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-monomorphization
Area: Monomorphization
C-bug
Category: This is a bug.
E-needs-mcve
Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
F-adt_const_params
`#![feature(adt_const_params)]`
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
requires-incomplete-features
This issue requires the use of incomplete features.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
I'm not sure where to start in terms of a minimal example, but the relevant code is https://github.com/shosti/tensrus/tree/compiler-bug (reproducible with
cargo test
). The code makes extensive use ofadt_const_params
andgeneric_const_exprs
.Meta
rustc --version --verbose
:Error output
Backtrace
rustc-ice-2024-06-06T15_38_19-35349.txt
The text was updated successfully, but these errors were encountered: