nalgebra
nalgebra copied to clipboard
Rust-analyzer can't figure out types
Hello,
This is not really an issue with the library but rather a poll to know if others ran into this issue. I'm using VSCode with the latest rust-analyzer extension and I get errors on all vector creation since nalgebra 0.27.1 (during cargo check only, it compiles just fine).
I defined a typedef pub type Vector2f = Vector2<Float> and if I call let v = Vector2f::new(1.0,1.0); I get
Expected 4 arguments, found 2 rust-analyzer mismatched-arg-count from the rust-analyzer. Note that manually using cargo check does work it's only an issue with the rust-analyzer.
Did anyone else encounter this issue, or has a combination of rust-analyzer/ rust version that doesn't have that issue?
I'm using the rustc 1.54.0-nightly compiler
Best, Philippe
I have the same issue. Adding,
"rust-analyzer.diagnostics.disabled": [ "mismatched-arg-count" ]
to settings.json in VSCode gets rid of that class of warning if you want a little less noise. I have no idea what is causing it.
Thanks for the tip, I suppose this is somehow related to const generics as it only appeared from then on, hope it gets fixed soonish :)
There is an open issue in rust-analyzer repo. Honestly, I don't think it will be fixed soon.
That issue is now closed, but the problem is not completely solved. Nalgebra uses typenum for defining its type aliases, which is too complex for r-a to evaluate in the foreseeable future. Things will become better if nalgebra defines its type aliases simply as type U6 = Const<6>; not as type U6 = Const<{ typenum::U6::USIZE }>;.
I run into this all the time and would rather not turn off mismatched-arg-count. Is there any downside to redefining type aliases in the way @HKalbasi explains?
What I said above is actually done in #1098. Do you use a version that has that commit?
I was unaware! I probably need to bump. Thanks!
@schell That change hasn’t been released to crates.io yet (will be at the end of the month).
Ah, ok, that's why then. Good to hear!