Skip to content

rust-analyzer fails to load the workspace partially #15341

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

Closed
Robbepop opened this issue Jul 26, 2023 · 8 comments
Closed

rust-analyzer fails to load the workspace partially #15341

Robbepop opened this issue Jul 26, 2023 · 8 comments
Labels
C-bug Category: bug

Comments

@Robbepop
Copy link
Contributor

Robbepop commented Jul 26, 2023

Since a few days rust-analyzer started to fail loading test-only parts of my workspace with the following message that constantly pops up as soon as I touch those test files:

image

Additionally it constantly creates the following file in .vscode/settings.json:
(Although this settings.json file does not even help with the problem.)

{
    "rust-analyzer.linkedProjects": [
        "./Cargo.toml"
    ]
}

This is a huge issue for me because I can no longer test and debug individual test files.
The whole IDE experience for my tests is gone. I reported this only now since I hoped the problem would resolve itself quickly.

The project with which I am experiencing this issue is: https://github.com/paritytech/wasmi
And in particular I am currently working on this branch: https://github.com/paritytech/wasmi/tree/rf-engine-regmach

It is important to note that the non-test related parts of the workspace seem to load fine.

@Robbepop Robbepop added the C-bug Category: bug label Jul 26, 2023
@Robbepop Robbepop changed the title rust-analyzer fails to load the workspace rust-analyzer fails to load the workspace partially Jul 26, 2023
@lnicola
Copy link
Member

lnicola commented Jul 26, 2023

Which files? IDE features work fine for me in crates/wasmi/tests/e2e/v1/func.rs, for example.

@Robbepop
Copy link
Contributor Author

Robbepop commented Jul 26, 2023

Ah sorry! Forgot to mention the most important detail ...

It is about files in this directory:
https://github.com/paritytech/wasmi/tree/rf-engine-regmach/crates/wasmi/src/engine/tests/regmach

It seems that rust-analyzer has problems with the #[cfg(test)] annotation on the mod tests; in crates/wasmi/src/engine/mod.rs. If I remove it rust-analyzer starts to properly load the test files again, however, it is obviously bad since they require a #[cfg(test)] to properly compile. Putting the #![cfg(test)] on the crates/wasmi/src/engine/tests/regmach/mod.rs file instead does not work either.

@lnicola
Copy link
Member

lnicola commented Jul 26, 2023

We enable cfg(miri) since #15284.

@Robbepop
Copy link
Contributor Author

Robbepop commented Jul 26, 2023

Unfortunately miri is far too slow to check those tests in a practical amount of time, therefore we disabled miri for quite some time. Only recently did it become a problem - which makes sense given that #15284 is only roughly 2 weeks old.
In CI we check miri passes all enabled tests, and since the tests in the regmach directory were impractical to execute via miri we had to disable them. Obviously being able to run those tests on miri would be ideal, yet we do not have the required super computer. :D

Removing #[cfg(miri)] makes rust-analyzer work again (so thanks for that a lot!), however, this is not a real solution due to the problems stated above.

@lnicola
Copy link
Member

lnicola commented Jul 26, 2023

It's a bit more work, but you can ignore individual tests with e.g. #[cfg_attr(miri, ignore)]. That PR enables us to interpret more of the standard library code, which will become more and more important for IDE features.

@Robbepop
Copy link
Contributor Author

Robbepop commented Jul 26, 2023

It's a bit more work, but you can ignore individual tests with e.g. #[cfg_attr(miri, ignore)]. That PR enables us to interpret more of the standard library code, which will become more and more important for IDE features.

Hmmm, indeed a lot of work given that there are well over a 1000 tests but on a second thought probably also the way conditional tests like these should actually have been handled in the first place. 🤔 Thanks!

This issue can be closed I guess. Thanks again!

@lnicola
Copy link
Member

lnicola commented Jul 26, 2023

indeed a lot of work given that there are well over a 1000 tests

wasmi-labs/wasmi#744 might do it, I didn't test.

We might also add a cfg(rust_analyzer) in the future, but I can't promise it.

@Robbepop
Copy link
Contributor Author

Robbepop commented Jul 26, 2023

Solution for the issue has been found. Thanks to @lnicola for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants