Skip to content

Commit fb56406

Browse files
committed
Cleanup
1 parent 5821a61 commit fb56406

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/cargo/core/workspace.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,17 +1703,16 @@ fn find_workspace_root_with_loader(
17031703
) -> CargoResult<Option<PathBuf>> {
17041704
// Check if there are any workspace roots that have already been found that would work
17051705
{
1706-
let mut parent = manifest_path.parent();
17071706
let roots = config.ws_roots.borrow();
1708-
while let Some(current) = parent {
1707+
// Iterate through the manifests parent directories until we find a workspace
1708+
// root. Note we skip the first item since that is just the path itself
1709+
for current in manifest_path.ancestors().skip(1) {
17091710
if let Some(ws_config) = roots.get(current) {
17101711
if !ws_config.is_excluded(manifest_path) {
17111712
// Add `Cargo.toml` since ws_root is the root and not the file
17121713
return Ok(Some(current.join("Cargo.toml")));
17131714
}
17141715
}
1715-
1716-
parent = current.parent();
17171716
}
17181717
}
17191718

0 commit comments

Comments
 (0)