Regression: Semantics::file_to_module_def
sometimes returns no result on Windows DOS device paths
#18894
Labels
C-bug
Category: bug
When using rust-analyzer as a library for analysis, rust analyzer has started to flakily misbehave on Windows paths. This was first seen in github/codeql#18443, but I've managed to reduce the issue in this repository.
What I do is to load a project contained in a workspace using
ra_ap_load-cargo::load_workspace_at
with default settings, then starting from a path to a module in the crate do some dance to map it to a file ID in the VFS (going fromPathBuf
toUtf8PathBuf
, then toAbsPathBuf
, then toVfsPath
), and then callSemantics::file_to_module_def
. This should work, but in some cases fails on Windows if the initial path is a DOS device path (i.e.//?/
prefixed paths), which is whatPathBuf::canonicalize
will return on Windows.This can be seen running this workflow.
Some things I've noticed
rust-analyzer version: 0.0.257
rustc version: 1.83
editor or extension: none (using rust-anlyzer as a library)
relevant settings: (eg. client settings, or environment variables like
CARGO
,RUSTC
,RUSTUP_HOME
orCARGO_HOME
)repository link (if public, optional): https://github.com/redsun82/rust-analyzer-windows-issue
code snippet to reproduce: see https://github.com/redsun82/rust-analyzer-windows-issue/blob/main/tests/load.rs, failure can be seen on windows running
cargo test
multiple timesThe text was updated successfully, but these errors were encountered: