rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.62k stars 1.49k forks source link

Errors not reported for some types of errors in test code #17156

Closed martinmr closed 3 weeks ago

martinmr commented 3 weeks ago

I stopped getting warnings and errors occasionally. Some errors are reported correctly, while others are not. There are some cases below in the snippet. After some debugging on my end, this only happens inside tests and not in library code, which works correctly all the time. It's not just a highlighting issue because I don't see the errors in the Problems tab either.

All errors are correctly diagnosed when calling cargo test directly.

rust-analyzer version: rust-analyzer version: 0.4.1937-standalone but also tried the most recent release version. rustc version: rustc 1.77.2 (25ef9e3d8 2024-04-09) editor or extension: VSCode, extension version is v0.4.1937 (pre-release)

// Here's an example, although it also happens outside of macros in other instances.
assert!(asdkfjalsdf jk k l l) // No warnings on obvious nonsense inside assert!
asdkfjalsdf jk k l l // Errors are reported as expected on the same code outside of assert!

// another example
UnimportedLibraryWithTypo_sksksk::new(); // no error despite the library not existing
UnimportedLibraryWithTypo_sksksk::new();skksks // but obvious syntax errors are reported
UnimportedLibraryWithTypo_sksksk::new();skksks; // Adding a colon makes the error go away though.
martinmr commented 3 weeks ago

Update: I switched to the current release version, which no longer crashes but now exhibits the exact same behavior.

martinmr commented 3 weeks ago

My bad, I overrode the command to use clippy, which skips the tests.