From aaa0771719c0ec8a9104896ce9fdc99e95c1805e Mon Sep 17 00:00:00 2001 From: rainy-me Date: Thu, 7 Oct 2021 23:44:25 +0900 Subject: [PATCH] Fix: compare pkg via manifest --- crates/rust-analyzer/src/handlers.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index a7ca5a7a3466..306de0425172 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -30,7 +30,6 @@ use project_model::{ProjectWorkspace, TargetKind}; use serde_json::json; use stdx::{format_to, never}; use syntax::{algo, ast, AstNode, TextRange, TextSize, T}; -use vfs::AbsPath; use crate::{ cargo_target_spec::CargoTargetSpec, @@ -615,21 +614,7 @@ pub(crate) fn handle_parent_module( .filter_map(|ws| match ws { ProjectWorkspace::Cargo { cargo, .. } => cargo .packages() - .find(|&pkg| { - cargo[pkg] - .targets - .iter() - .find_map(|&it| { - let pkg_parent_path = cargo[it].root.parent()?; - let file_parent_path = AbsPath::assert(file_path.parent()?); - if pkg_parent_path == file_parent_path { - Some(()) - } else { - None - } - }) - .is_some() - }) + .find(|&pkg| cargo[pkg].manifest.as_ref() == file_path) .and_then(|_| Some(cargo)), _ => None, })