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
fix: VFS should not confuse paths with source roots that have the same prefix #17019
Conversation
19f8a49
to
b388c50
Compare
Thanks! |
fix: VFS should not confuse paths with source roots that have the same prefix Previously, the VFS would assign paths to the source root that had the longest string prefix match. This would break when we had source roots in subdirectories: ``` /foo /foo/bar ``` Given a file `/foo/bar_baz.rs`, we would attribute it to `/foo/bar` source root, which is wrong. As a result, we would attribute paths to the wrong crate when a crate was in a subdirectory of another one. This is more common in larger monorepos, but could occur in any Rust project. Fix this in the VFS, and add a test.
💔 Test failed - checks-actions |
🤔 why is this failing on merge only, judging from the commit parents this is a recent branch so there shouldn't be any semantic conflicts I think? |
According to CI log, the following tests fail on Windows
and it seems that CI runs Windows tests on merges, but not on PRs, so it fails on merge only. rust-analyzer/.github/workflows/ci.yaml Lines 93 to 95 in 7a8374c
|
Yeah, I wondered whether I should be unconditionally appending There doesn't seem to be a @ShoyuVanilla huh, that seems unfortunate. Maybe PRs should also run Windows tests? |
8885d30
to
869e2fd
Compare
Aha, there is a |
Previously PRs would only do a build on Windows, which confusingly meant that PRs got a green tick for Windows despite not testing them. See discussion in rust-lang#17019.
869e2fd
to
b03844d
Compare
Though I don't know about the r-a CI policy but in my naive opinion, running tests for each major platforms would be good for cases like filesystem or environment variables level changes like in this issue and running it wouldn't slow down CI much because each platform CI is done in different instances. |
@Veykril I think this PR is good to merge now, it's using |
Run Windows tests on PRs too Previously PRs would only do a build on Windows, which confusingly meant that PRs got a green tick for Windows despite not testing them. See discussion in #17019.
Thanks! |
☀️ Test successful - checks-actions |
Is this enough? Seems to me this will still result in /foo/bar_baz/quux.rs being attributed to /foo/bar rather than /foo. The correct solution is of course to add a final slash to prefixes, and add a final slash to the string to search as well if matching the prefix itself is needed. And of course normalize separators and UNC long paths beforehand if running on Windows. |
Previously, the VFS would assign paths to the source root that had the longest string prefix match. This would break when we had source roots in subdirectories:
Given a file
/foo/bar_baz.rs
, we would attribute it to the/foo/bar
source root, which is wrong.As a result, we would attribute paths to the wrong crate when a crate was in a subdirectory of another one. This is more common in larger monorepos, but could occur in any Rust project.
Fix this in the VFS, and add a test.