Skip to content

Commit

Permalink
fix: Nomarlize the relative path for bin target
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Sep 5, 2024
1 parent ad389f0 commit e14e582
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/cargo/util/toml/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::fs::{self, DirEntry};
use std::path::{Path, PathBuf};

use anyhow::Context as _;
use cargo_util::paths;
use cargo_util_schemas::manifest::{
PathValue, StringOrBool, StringOrVec, TomlBenchTarget, TomlBinTarget, TomlExampleTarget,
TomlLibTarget, TomlManifest, TomlTarget, TomlTestTarget,
Expand Down Expand Up @@ -315,7 +316,9 @@ fn to_bin_targets(

let mut result = Vec::new();
for bin in bins {
let path = package_root.join(&bin.path.as_ref().expect("previously normalized").0);
let path = package_root.join(paths::normalize_path(
&bin.path.as_ref().expect("previously normalized").0,
));
let mut target = Target::bin_target(
name_or_panic(bin),
bin.filename.clone(),
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/binary_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ fn bin_target_with_relative_path() {
.with_stderr_data(str![[r#"
[CHECKING] relative-bar v0.1.0 ([ROOT]/foo/relative-bar)
[WARNING] unused variable: `a`
--> relative-bar/./src/main.rs:1:17
--> relative-bar/src/main.rs:1:17
|
1 | fn main() { let a = 1; }
| ^ [HELP] if this is intentional, prefix it with an underscore: `_a`
Expand Down

0 comments on commit e14e582

Please sign in to comment.