Skip to content

Commit 7fd08f4

Browse files
committed
Handle Cargo.toml manifests that are symlinks
The canonicalize() function resolves symlinks, which would cause targets whose "Cargo.toml" is a symlink to be filtered out. This would cause `cargo-fmt` to print an error "Failed to find targets". Resolves rust-lang#6184
1 parent c97996f commit 7fd08f4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/cargo-fmt/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,10 @@ fn get_targets_root_only(
384384
.packages
385385
.into_iter()
386386
.filter(|p| {
387+
let manifest_path = PathBuf::from(&p.manifest_path);
387388
in_workspace_root
388-
|| PathBuf::from(&p.manifest_path)
389-
.canonicalize()
390-
.unwrap_or_default()
391-
== current_dir_manifest
389+
|| manifest_path == current_dir_manifest
390+
|| manifest_path.canonicalize().unwrap_or_default() == current_dir_manifest
392391
})
393392
.flat_map(|p| p.targets)
394393
.collect(),

0 commit comments

Comments
 (0)