-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conflicting trait impls cause ICE with generic_const_exprs
#119692
Comments
found 7 bors merge commits in the specified range |
@rustbot label +requires-incomplete-features +F-adt_const_params +F-generic_const_exprs +requires-nightly -needs-triage |
Much better minimization found by @pacak and @theemathas in #126078: #![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
|
Code (Playground)
The code should not compile, since the first two trait impls are conflicting. If
generic_const_exprs
is disabled (it is not needed code-wise in this reduced example, but was necessary in my original code), the compiler gives the correct error message:Note that the even the third trait impl is needed in order to reproduce the ICE. The code compiles fine if either the second or the third trait impl is removed (the first one is actually used, so it cant be removed).
Meta
rustc --version --verbose
:Error output
Backtrace
rustc-ice-2024-01-07T13_58_40-55799.txt
The text was updated successfully, but these errors were encountered: