Skip to content

Commit 5821a61

Browse files
committed
Fix workspace resolution
1 parent 82a8fb4 commit 5821a61

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/cargo/core/workspace.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,10 +1702,18 @@ fn find_workspace_root_with_loader(
17021702
mut loader: impl FnMut(&Path) -> CargoResult<Option<PathBuf>>,
17031703
) -> CargoResult<Option<PathBuf>> {
17041704
// Check if there are any workspace roots that have already been found that would work
1705-
for (ws_root, ws_root_config) in config.ws_roots.borrow().iter() {
1706-
if manifest_path.starts_with(ws_root) && !ws_root_config.is_excluded(manifest_path) {
1707-
// Add `Cargo.toml` since ws_root is the root and not the file
1708-
return Ok(Some(ws_root.join("Cargo.toml").clone()));
1705+
{
1706+
let mut parent = manifest_path.parent();
1707+
let roots = config.ws_roots.borrow();
1708+
while let Some(current) = parent {
1709+
if let Some(ws_config) = roots.get(current) {
1710+
if !ws_config.is_excluded(manifest_path) {
1711+
// Add `Cargo.toml` since ws_root is the root and not the file
1712+
return Ok(Some(current.join("Cargo.toml")));
1713+
}
1714+
}
1715+
1716+
parent = current.parent();
17091717
}
17101718
}
17111719

0 commit comments

Comments
 (0)