Skip to content

Commit ac1dbe0

Browse files
author
Bogdan Mircea
committed
improve crate spec merging
1 parent ea06599 commit ac1dbe0

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

tools/rust_analyzer/aquery.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,29 @@ fn consolidate_crate_specs(crate_specs: Vec<CrateSpec>) -> anyhow::Result<BTreeS
203203
log::debug!("{:?}", spec);
204204
if let Some(existing) = consolidated_specs.get_mut(&spec.crate_id) {
205205
existing.deps.extend(spec.deps);
206+
existing.env.extend(spec.env);
206207

207208
spec.cfg.retain(|cfg| !existing.cfg.contains(cfg));
208209
existing.cfg.extend(spec.cfg);
209210

211+
if let Some(source) = spec.source {
212+
let existing_source = existing.source.get_or_insert_with(|| CrateSpecSource {
213+
exclude_dirs: Vec::new(),
214+
include_dirs: Vec::new(),
215+
});
216+
217+
existing_source.exclude_dirs.extend(source.exclude_dirs);
218+
existing_source.include_dirs.extend(source.include_dirs);
219+
}
220+
210221
// display_name should match the library's crate name because Rust Analyzer
211222
// seems to use display_name for matching crate entries in rust-project.json
212223
// against symbols in source files. For more details, see
213224
// https://github.com/bazelbuild/rules_rust/issues/1032
214225
if spec.crate_type == CrateType::Rlib {
215226
existing.display_name = spec.display_name;
216-
existing.crate_type = CrateType::Rlib
227+
existing.crate_type = CrateType::Rlib;
228+
existing.build = spec.build;
217229
}
218230

219231
// For proc-macro crates that exist within the workspace, there will be a

tools/rust_analyzer/rust_project.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ pub struct Runnable {
217217
#[derive(Debug, Clone, Copy, Serialize)]
218218
#[serde(rename_all = "camelCase")]
219219
pub enum RunnableKind {
220-
/// This seems useless in the RA code.
221220
Check,
222221

223222
/// Can run a binary.

0 commit comments

Comments
 (0)