Skip to content

Commit

Permalink
Handle Cargo.toml manifests that are symlinks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmfink committed Jun 7, 2024
1 parent c97996f commit 7fd08f4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/cargo-fmt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,10 @@ fn get_targets_root_only(
.packages
.into_iter()
.filter(|p| {
let manifest_path = PathBuf::from(&p.manifest_path);
in_workspace_root
|| PathBuf::from(&p.manifest_path)
.canonicalize()
.unwrap_or_default()
== current_dir_manifest
|| manifest_path == current_dir_manifest
|| manifest_path.canonicalize().unwrap_or_default() == current_dir_manifest
})
.flat_map(|p| p.targets)
.collect(),
Expand Down

0 comments on commit 7fd08f4

Please sign in to comment.