diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-20 11:36:28 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-20 11:36:28 +0100 |
commit | be762ccccd5a86632e60351518528d078785a3e2 (patch) | |
tree | 7ebc1b5d72a14704dfe8539a039b2acda29bdf64 /crates/base_db/src | |
parent | 4c00bdea675d33d578cff1c0d7cc3967303e6653 (diff) | |
parent | 7a21e9302e194d5ed2a008417130c54cfa52ca24 (diff) |
Merge #6294
6294: Add a hacky remidy for #6038 r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/base_db/src')
-rw-r--r-- | crates/base_db/src/input.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index 215ac4b41..b870e2cee 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs | |||
@@ -290,6 +290,29 @@ impl CrateGraph { | |||
290 | } | 290 | } |
291 | false | 291 | false |
292 | } | 292 | } |
293 | |||
294 | // Work around for https://github.com/rust-analyzer/rust-analyzer/issues/6038. | ||
295 | // As hacky as it gets. | ||
296 | pub fn patch_cfg_if(&mut self) -> bool { | ||
297 | let cfg_if = self.hacky_find_crate("cfg_if"); | ||
298 | let std = self.hacky_find_crate("std"); | ||
299 | match (cfg_if, std) { | ||
300 | (Some(cfg_if), Some(std)) => { | ||
301 | self.arena.get_mut(&cfg_if).unwrap().dependencies.clear(); | ||
302 | self.arena | ||
303 | .get_mut(&std) | ||
304 | .unwrap() | ||
305 | .dependencies | ||
306 | .push(Dependency { crate_id: cfg_if, name: CrateName::new("cfg_if").unwrap() }); | ||
307 | true | ||
308 | } | ||
309 | _ => false, | ||
310 | } | ||
311 | } | ||
312 | |||
313 | fn hacky_find_crate(&self, declaration_name: &str) -> Option<CrateId> { | ||
314 | self.iter().find(|it| self[*it].declaration_name.as_deref() == Some(declaration_name)) | ||
315 | } | ||
293 | } | 316 | } |
294 | 317 | ||
295 | impl ops::Index<CrateId> for CrateGraph { | 318 | impl ops::Index<CrateId> for CrateGraph { |