From 367aa4059d19267b49a529e12dc41c2acb1b72c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gammels=C3=A6ter?= Date: Wed, 4 Dec 2024 21:06:52 +0100 Subject: [PATCH 1/2] Merge include/exclude dirs when consolidating crate specs This fixes //test/rust_analyzer:rust_analyzer_test which seems to currently fail on main branch. --- tools/rust_analyzer/aquery.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/rust_analyzer/aquery.rs b/tools/rust_analyzer/aquery.rs index bc98913b05..2c634b04b1 100644 --- a/tools/rust_analyzer/aquery.rs +++ b/tools/rust_analyzer/aquery.rs @@ -181,6 +181,15 @@ fn consolidate_crate_specs(crate_specs: Vec) -> anyhow::Result existing.source = new, + (Some(existing_source), Some(new_source)) => { + existing_source.exclude_dirs.extend(new_source.exclude_dirs); + existing_source.include_dirs.extend(new_source.include_dirs); + } + _ => (), + } + // display_name should match the library's crate name because Rust Analyzer // seems to use display_name for matching crate entries in rust-project.json // against symbols in source files. For more details, see From 284f5a21dd64720246b45cec4389a0d6da816483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gammels=C3=A6ter?= Date: Wed, 4 Dec 2024 21:06:53 +0100 Subject: [PATCH 2/2] Prefer workspace for root_module path --- .../generated_srcs_test/rust_project_json_test.rs | 4 +++- tools/rust_analyzer/aquery.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/test/rust_analyzer/generated_srcs_test/rust_project_json_test.rs b/test/rust_analyzer/generated_srcs_test/rust_project_json_test.rs index 81fe369554..71ab6ba1ea 100644 --- a/test/rust_analyzer/generated_srcs_test/rust_project_json_test.rs +++ b/test/rust_analyzer/generated_srcs_test/rust_project_json_test.rs @@ -48,7 +48,9 @@ mod tests { .find(|c| &c.display_name == "generated_srcs") .unwrap(); assert!(gen.root_module.starts_with("/")); - assert!(gen.root_module.ends_with("/lib.rs")); + assert!(gen + .root_module + .ends_with("rules_rust_test_rust_analyzer/lib.rs")); let include_dirs = &gen.source.as_ref().unwrap().include_dirs; assert!(include_dirs.len() == 1); diff --git a/tools/rust_analyzer/aquery.rs b/tools/rust_analyzer/aquery.rs index 2c634b04b1..acfea6cb14 100644 --- a/tools/rust_analyzer/aquery.rs +++ b/tools/rust_analyzer/aquery.rs @@ -208,6 +208,15 @@ fn consolidate_crate_specs(crate_specs: Vec) -> anyhow::Result