Fix misuse of ?

This exited the whole loop instead of having continue semantics and
continuing to find workspaces. So wrap in find_map.
This commit is contained in:
Cormac Relf 2025-12-02 14:11:52 +11:00
parent ac641771a8
commit 3b97d38702

View file

@ -847,21 +847,18 @@ impl GlobalStateSnapshot {
&self,
package: &Arc<PackageId>,
) -> Option<FxHashSet<Arc<PackageId>>> {
for workspace in self.workspaces.iter() {
match &workspace.kind {
ProjectWorkspaceKind::Cargo { cargo, .. }
| ProjectWorkspaceKind::DetachedFile { cargo: Some((cargo, _, _)), .. } => {
let package = cargo.packages().find(|p| cargo[*p].id == *package)?;
self.workspaces.iter().find_map(|workspace| match &workspace.kind {
ProjectWorkspaceKind::Cargo { cargo, .. }
| ProjectWorkspaceKind::DetachedFile { cargo: Some((cargo, _, _)), .. } => {
let package = cargo.packages().find(|p| cargo[*p].id == *package)?;
return cargo[package]
.all_member_deps
.as_ref()
.map(|deps| deps.iter().map(|dep| cargo[*dep].id.clone()).collect());
}
_ => {}
return cargo[package]
.all_member_deps
.as_ref()
.map(|deps| deps.iter().map(|dep| cargo[*dep].id.clone()).collect());
}
}
None
_ => None,
})
}
pub(crate) fn file_exists(&self, file_id: FileId) -> bool {