Skip to content

Commit 9df9cd9

Browse files
committed
Use compatible Windows paths in output
1 parent ca3e3f8 commit 9df9cd9

13 files changed

Lines changed: 57 additions & 13 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cargo-dylint/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dylint_internal = { version = "=6.3.2", path = "../internal" }
2525
assert_cmd = { workspace = true }
2626
cargo_metadata = { workspace = true }
2727
ctor = { workspace = true }
28+
dunce = { workspace = true }
2829
glob = { workspace = true }
2930
ignore = { workspace = true }
3031
log = { workspace = true }

‎cargo-dylint/tests/ci.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn markdown_does_not_use_inline_links() {
427427
assert!(
428428
!re.is_match(&markdown),
429429
"`{}` uses inline links",
430-
path.canonicalize().unwrap().to_string_lossy()
430+
dunce::canonicalize(path).unwrap().to_string_lossy()
431431
);
432432
}
433433
}
@@ -451,7 +451,7 @@ fn markdown_reference_links_are_sorted() {
451451
assert!(
452452
links_sorted == links,
453453
"contents of `{}` are not what was expected:\n{}\n",
454-
path.canonicalize().unwrap().to_string_lossy(),
454+
dunce::canonicalize(path).unwrap().to_string_lossy(),
455455
links_sorted.join("\n")
456456
);
457457
}

‎cargo-dylint/tests/integration/list.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,5 @@ fn list_by_path() {
258258
fn target_debug(dir: &Path) -> Result<PathBuf> {
259259
let metadata = dylint_internal::cargo::metadata(dir)?;
260260
let debug_dir = metadata.target_directory.join("debug");
261-
debug_dir
262-
.canonicalize()
263-
.with_context(|| format!("Could not canonicalize {debug_dir:?}"))
261+
dunce::canonicalize(&debug_dir).with_context(|| format!("Could not canonicalize `{debug_dir}`"))
264262
}

‎dylint/Cargo.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cargo-util = { workspace = true, optional = true }
1616
cargo-util-schemas = { workspace = true, optional = true }
1717
cargo_metadata = { workspace = true }
1818
chrono = { workspace = true, optional = true }
19-
dunce = { workspace = true, optional = true }
19+
dunce = { workspace = true }
2020
fs_extra = { workspace = true, optional = true }
2121
glob = { workspace = true, optional = true }
2222
heck = { workspace = true, optional = true }
@@ -83,7 +83,6 @@ package_options = [
8383
__cargo_cli = [
8484
"cargo-util",
8585
"cargo-util-schemas",
86-
"dunce",
8786
"dylint_internal/home",
8887
"fs_extra",
8988
"glob",

‎dylint/src/lib.rs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ where
300300
}
301301

302302
fn name_as_path(name: &str, as_path_only: bool) -> Result<Option<(String, PathBuf)>> {
303-
if let Ok(path) = PathBuf::from(name).canonicalize() {
303+
if let Ok(path) = dunce::canonicalize(name) {
304304
if let Some((_, toolchain)) = parse_path_with_toolchain(&path) {
305305
return Ok(Some((toolchain, path)));
306306
}
@@ -482,17 +482,19 @@ fn list_lints(opts: &opts::Dylint, resolved: &ToolchainMap) -> Result<()> {
482482

483483
fn display_location(path: &Path) -> Result<String> {
484484
let current_dir = current_dir().with_context(|| "Could not get current directory")?;
485+
let current_dir_canonicalized = current_dir
486+
.canonicalize()
487+
.with_context(|| format!("Could not canonicalize `{}`", current_dir.display()))?;
485488
let Ok(path_buf) = path.canonicalize() else {
486489
return Ok("<unbuilt>".to_owned());
487490
};
488491
let parent = path_buf
489492
.parent()
490493
.ok_or_else(|| anyhow!("Could not get parent directory"))?;
491-
Ok(parent
492-
.strip_prefix(&current_dir)
493-
.unwrap_or(parent)
494-
.to_string_lossy()
495-
.to_string())
494+
let location = parent
495+
.strip_prefix(&current_dir_canonicalized)
496+
.unwrap_or(parent);
497+
Ok(dunce::simplified(location).to_string_lossy().to_string())
496498
}
497499

498500
fn clippy_disable_docs_links() -> Result<String> {

‎examples/experimental/derive_opportunity/Cargo.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/experimental/missing_doc_comment_llm/Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/general/Cargo.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/restriction/Cargo.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)