-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler panic when indexing associated, constant array of generic length in test #88365
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
Comments
Full backtrace:
|
Can't reproduce, tried like this:
Output of the last command:
Rustc version:
Can you create a self-contained Git repo, with which the panic can be reproduced after |
Hi You're right, I actually should have tried to reproduce the panic in an isolated repo first. Now I discovered that this doesn't just apply to Full code: #![feature(const_generics)] // <- Will not panic if removed
fn main() {
use core::ops::Index;
trait MyTrait {
type ArrayType: Index<usize, Output = u8>;
const SIZE: usize;
const ARRAY: Self::ArrayType;
}
struct MyStruct;
impl MyTrait for MyStruct {
type ArrayType = [u8; Self::SIZE];
const SIZE: usize = 4;
const ARRAY: [u8; Self::SIZE] = [1, 2, 3, 4];
}
let res = <MyStruct as MyTrait>::ARRAY[2]; // PANICS HERE
assert_eq!(res, 3);
} Now you can just
|
Update: now you need |
I tried to narrow it down as much as I could:
When executing
RUST_BACKTRACE=1 cargo test some_test
:NOTE: Weirdly enough, this does not happen when running(see #88365 (comment))cargo build
or evencargo run
.The text was updated successfully, but these errors were encountered: