|
15 | 15 | // FIXME: This is a mess that needs some untangling work |
16 | 16 | use std::{iter, mem, sync::atomic::AtomicUsize, time::Duration}; |
17 | 17 |
|
18 | | -use hir::{ChangeWithProcMacros, ProcMacrosBuilder, db::DefDatabase}; |
| 18 | +use hir::{ChangeWithProcMacros, ProcMacrosBuilder}; |
19 | 19 | use ide_db::{ |
20 | 20 | FxHashMap, |
21 | | - base_db::{CrateGraphBuilder, ProcMacroLoadingError, ProcMacroPaths, salsa::Durability}, |
| 21 | + base_db::{ |
| 22 | + CrateGraphBuilder, ProcMacroLoadingError, ProcMacroPaths, |
| 23 | + salsa::{Durability, Setter}, |
| 24 | + }, |
22 | 25 | }; |
23 | 26 | use itertools::Itertools; |
24 | 27 | use load_cargo::{ProjectFolders, load_proc_macro}; |
@@ -109,13 +112,20 @@ impl GlobalState { |
109 | 112 | self.reload_flycheck(); |
110 | 113 | } |
111 | 114 |
|
112 | | - if self.analysis_host.raw_database().expand_proc_attr_macros() |
113 | | - != self.config.expand_proc_attr_macros() |
114 | | - { |
115 | | - self.analysis_host.raw_database_mut().set_expand_proc_attr_macros_with_durability( |
116 | | - self.config.expand_proc_attr_macros(), |
117 | | - Durability::HIGH, |
118 | | - ); |
| 115 | + // TODO: `ide`'s Cargo.toml says that it should avoid depending on `hir-*` crates directly, |
| 116 | + // and go through `hir` re-exports instead. `rust-analyzer` OTOH does seems to depend on `hir-*` |
| 117 | + // after all. So, should I import `ExpandProcAttrMacros` through `hir` or `hir_def`? |
| 118 | + // TODO: should I create `AnalysisHost::{update_,}expand_proc_attr_macros` to clean this up? |
| 119 | + // TODO: we don't use `raw_db` mutably until we go into the `if` -- is it a problem that I |
| 120 | + // still get it mutably in an eager manner? I did this to avoid needing two separate calls, to |
| 121 | + // `raw_database` and `raw_database_mut`. Or maybe I should just inline `raw_db`? |
| 122 | + let raw_db = self.analysis_host.raw_database_mut(); |
| 123 | + let expand_proc_macros = hir::db::ExpandProcAttrMacros::get(raw_db); |
| 124 | + if expand_proc_macros.enabled(raw_db) != self.config.expand_proc_attr_macros() { |
| 125 | + expand_proc_macros |
| 126 | + .set_enabled(raw_db) |
| 127 | + .with_durability(Durability::HIGH) |
| 128 | + .to(self.config.expand_proc_attr_macros()); |
119 | 129 | } |
120 | 130 |
|
121 | 131 | if self.config.cargo(None) != old_config.cargo(None) { |
|
0 commit comments