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 bc98913b05..acfea6cb14 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 @@ -199,6 +208,15 @@ fn consolidate_crate_specs(crate_specs: Vec) -> anyhow::Result