Skip to content

Commit aaa0771

Browse files
committed
Fix: compare pkg via manifest
1 parent 39044fe commit aaa0771

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use project_model::{ProjectWorkspace, TargetKind};
3030
use serde_json::json;
3131
use stdx::{format_to, never};
3232
use syntax::{algo, ast, AstNode, TextRange, TextSize, T};
33-
use vfs::AbsPath;
3433

3534
use crate::{
3635
cargo_target_spec::CargoTargetSpec,
@@ -615,21 +614,7 @@ pub(crate) fn handle_parent_module(
615614
.filter_map(|ws| match ws {
616615
ProjectWorkspace::Cargo { cargo, .. } => cargo
617616
.packages()
618-
.find(|&pkg| {
619-
cargo[pkg]
620-
.targets
621-
.iter()
622-
.find_map(|&it| {
623-
let pkg_parent_path = cargo[it].root.parent()?;
624-
let file_parent_path = AbsPath::assert(file_path.parent()?);
625-
if pkg_parent_path == file_parent_path {
626-
Some(())
627-
} else {
628-
None
629-
}
630-
})
631-
.is_some()
632-
})
617+
.find(|&pkg| cargo[pkg].manifest.as_ref() == file_path)
633618
.and_then(|_| Some(cargo)),
634619
_ => None,
635620
})

0 commit comments

Comments
 (0)