-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Compiler panic when using a slice pattern #59016
Comments
Also reproduces on nightly |
Reduced: trait Gen<T> {
fn gen(x: Self) -> T;
}
impl<T, F: FnOnce() -> T> Gen<T> for F {
fn gen(x: Self) -> T {
x()
}
}
fn array() -> impl Gen<[(); 0]> {
move || []
}
fn main() {
let [] = Gen::gen(array());
} |
Without closures: trait Gen<T> {
fn gen(x: Self) -> T;
}
struct A;
impl Gen<[(); 0]> for A {
fn gen(x: Self) -> [(); 0] {
[]
}
}
fn array() -> impl Gen<[(); 0]> {
A
}
fn main() {
let [] = Gen::gen(array());
} I believe the issue is that we aren't normalizing constants before trying to access their content. This makes me wonder if all uses of |
This comment has been minimized.
This comment has been minimized.
Basically all the rust/src/librustc_typeck/check/_match.rs Line 399 in ad8a3eb
I believe that the problem is that We basically have two options now:
|
I'm not sure if this is the same error, but I'm getting the same message on this code: fn testfn(_arr: &mut [();0]) {}
trait TestTrait {
fn method() {
}
impl TestTrait for [(); 0] {
fn method() {
let mut arr: Self = [(); 0];
testfn(&mut arr);
}
}
fn main() {} Everything compiles fine when I remove the Let me know if you'd like more details or the stack trace; If it's unrelated, I can also submit it as a new bug, but it sounds like this has the same root cause. |
Your example is unrelated to slice patterns, but a symptom of the same |
triage: Downgrading priority to P-medium. It seems like this problem, while potentially annoying, is not masking some underlying soundness hole or serious expressiveness bug. |
I got
thread 'rustc' panicked at 'expected `LazyConst` to contain a usize', src/libcore/option.rs:1038:5
when using a slice pattern.Example code:
Compiler output:
Compiler version:
Backtrace:
The text was updated successfully, but these errors were encountered: