-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust analyser panicked in VSC #11659
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
Can you reproduce this easily (maybe by running |
OK, what I get is the following, it seems to be the same error. I'll try agin in a minute with differeny code.
|
CC #10390 |
yes, it is a duplicate, sorry. |
It's fine, it may or may not be the same issue, and yours might be easier to minimize. A small test case would be lovely. |
I've tried some other code that is on github, but rust analyser is working with it. I'll look further. |
There's no easy way to minimize these, but you can start from the function that's shown last in |
Here's a relatively short module that exhibits the panic. I have pulled it out of a much larger program, so I don't know if it will fail properly on its own. Some code
Dump
|
That's a start, but I don't think it works asa reproduction. I would try to drop the proc macro (accessing the fields directly should work, if the getters don't do anything fancy) and include the structs that are used by the code. You might also be able to remove some of the fields, probably one is enough to trigger the crash. |
When I take the file out and copy it into a single-file crate, I do not get the panic in the small crate. |
I think you dropped the |
The following does crash as a stand-alone; I'll see if I can shorten it.
|
Slightly minimized: struct LinkArray<const N: usize, LD>(LD);
fn f<const N: usize, LD>(x: LD) -> LinkArray<N, LD> {
LinkArray::<N, LD>(x)
} |
Yes, can confirm. |
Does this mean we have to put the type parameters first and then the constants (in generics)? Is my code wrong? Or is this a rust analyser issue? |
It looks like reordering the arguments makes it work: struct LinkArray<LD, const N: usize>(LD);
fn f<LD, const N: usize>(x: LD) -> LinkArray<LD, N> {
LinkArray::<LD, N>(x)
} But (assuming out minimization has the same cause as your original crash) your code is correct. This was caused by a recent PR which made RA accept the generic arguments in any order. |
I think I may have found a related crash. Specifically the following code causes the server to crash: pub struct Vec2;
pub struct CurvePoint;
pub struct Mesh;
pub fn gen_curve<const N: usize>(curve: impl Iterator<Item = CurvePoint>, offsets: [Vec2; N],) -> Mesh {
todo!()
}
pub fn gen(curve: impl Iterator<Item = CurvePoint>) -> Mesh {
gen_curve(curve, [Vec2, Vec2, Vec2, Vec2])
} My best guess is that the server crashes due to placing the Type Generic after the Const Generic (as above), but it may be harder to see, since the type generic is actually created by the EDIT: |
works for me now thanks. |
wow, you guys are amazing — I was just wondering how to minimise and report and then I found this and tonight’s build fixes the issue |
@rkuhn http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/ is a very good for test case minimization, but in RA you can generally play it fast and loose because it works with code that doesn't compile. |
rust-analyzer version:
5fae65dd2 2022-03-07 stable
rustc version:
rustc 1.61.0-nightly (03918badd 2022-03-07)
relevant settings:
VSC version
Error dump as displayed
The text was updated successfully, but these errors were encountered: