nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

Rust-analyzer can't figure out types

Open WeiPhil opened this issue 4 years ago • 9 comments

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

WeiPhil avatar Jun 08 '21 09:06 WeiPhil

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.

computemachines avatar Jun 08 '21 21:06 computemachines

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 :)

WeiPhil avatar Jun 08 '21 22:06 WeiPhil

There is an open issue in rust-analyzer repo. Honestly, I don't think it will be fixed soon.

nickkuk avatar Jun 09 '21 05:06 nickkuk

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 }>;.

HKalbasi avatar Mar 20 '22 14:03 HKalbasi

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?

schell avatar Apr 10 '22 20:04 schell

What I said above is actually done in #1098. Do you use a version that has that commit?

HKalbasi avatar Apr 10 '22 21:04 HKalbasi

I was unaware! I probably need to bump. Thanks!

schell avatar Apr 11 '22 23:04 schell

@schell That change hasn’t been released to crates.io yet (will be at the end of the month).

sebcrozet avatar Apr 12 '22 06:04 sebcrozet

Ah, ok, that's why then. Good to hear!

schell avatar Apr 12 '22 21:04 schell