-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)A-console-outputArea: Terminal output, colors, progress bar, etc.Area: Terminal output, colors, progress bar, etc.C-bugCategory: bugCategory: bugO-windowsOS: WindowsOS: WindowsS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Description
Problem
When using a relative path in a workspace subproject, the file path in the diagnostic message contains duplicate separators
happened
mpv-easy-ext\./src/main.rs:2:7
expected
mpv-easy-ext/src/main.rs:2:7
cargo clippy
Checking mpv-easy-ext v0.1.0 (C:\wt\clippy-path\mpv-easy-ext)
warning: unused variable: `a`
--> mpv-easy-ext\./src/main.rs:2:7
|
2 | let a = 1;
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
= note: `#[warn(unused_variables)]` on by default
warning: `mpv-easy-ext` (bin "mpv") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
Steps
git clone https://github.com/ahaoboy/cargo-clippy-path
cd cargo-clippy-path
cargo clippy
Possible Solution(s)
Use clean-path to transform the output path
Notes
No response
Version
cargo 1.81.0-nightly (154fdac39 2024-07-07)
release: 1.81.0-nightly
commit-hash: 154fdac39ae9629954e19e9986fd2cf2cdd8d964
commit-date: 2024-07-07
host: x86_64-pc-windows-msvc
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.8.0-DEV (sys:0.4.73+curl-8.8.0 vendored ssl:Schannel)
os: Windows 10.0.22635 (Windows 11 Professional) [64-bit]
Metadata
Metadata
Assignees
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)A-console-outputArea: Terminal output, colors, progress bar, etc.Area: Terminal output, colors, progress bar, etc.C-bugCategory: bugCategory: bugO-windowsOS: WindowsOS: WindowsS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ahaoboy commentedon Jul 10, 2024
I don't know if it's a problem with cargo itself or if a dependent library doesn't process the path for Windows. rust-lang/rust-clippy#13078
epage commentedon Jul 10, 2024
Couple of questions
cargo check
?cargo metadata
show the non-cleaned path?epage commentedon Jul 10, 2024
Side note: I wonder if this is related to target work I did like #13849.
ahaoboy commentedon Jul 10, 2024
cargo check
cargo -Vv
cargo metadata
Yes
Yes
Yes "src_path":"C:\wt\clippy-path\mpv-easy-ext\./src/main.rs"
epage commentedon Jul 10, 2024
@ahaoboy Can you find a full reproduction case (manfiest, source files, etc). This can be by copy/pasting or a repo. A repo would make sure nothing was accidentally left out.
I'm assuming the problem is in cases like
cargo/src/cargo/util/toml/targets.rs
Line 318 in 4e19f31
I would assume we would have a call to https://docs.rs/cargo-util/latest/cargo_util/paths/fn.normalize_path.html in there. Might be good to go back some versions to see if this once worked and to identify the root cause to find where the best fix would be.
ahaoboy commentedon Jul 10, 2024
Steps
Ubuntu has same issue
The solution should not be difficult. Just find where the path mpv-easy-ext/./src/main.rs:2:7 is joined, and then use clean-path to process the following. cargo is too complicated, and I don’t know where the path is concatenated.
PS: Maybe we can use a clean-path-join library? The double separator does not affect the function at present, but it is impossible to jump through the link in some editors and terminals.
test: Add a test for issue rust-lang#14227
target
paths #14497test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
test: Add a test for issue rust-lang#14227
Auto merge of #14497 - linyihai:issue-14227, r=epage