Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/item_tree/lower.rs')
-rw-r--r--crates/hir-def/src/item_tree/lower.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/hir-def/src/item_tree/lower.rs b/crates/hir-def/src/item_tree/lower.rs
index 3f19e00154..31c6ef867d 100644
--- a/crates/hir-def/src/item_tree/lower.rs
+++ b/crates/hir-def/src/item_tree/lower.rs
@@ -2,7 +2,7 @@
use std::cell::OnceCell;
-use base_db::FxIndexSet;
+use base_db::{Crate, FxIndexSet};
use cfg::CfgOptions;
use hir_expand::{
HirFileId,
@@ -36,12 +36,13 @@ pub(super) struct Ctx<'a> {
span_map: OnceCell<SpanMap>,
file: HirFileId,
cfg_options: OnceCell<&'a CfgOptions>,
+ krate: Crate,
top_level: Vec<ModItemId>,
visibilities: FxIndexSet<RawVisibility>,
}
impl<'a> Ctx<'a> {
- pub(super) fn new(db: &'a dyn DefDatabase, file: HirFileId) -> Self {
+ pub(super) fn new(db: &'a dyn DefDatabase, file: HirFileId, krate: Crate) -> Self {
Self {
db,
tree: ItemTree::default(),
@@ -51,12 +52,13 @@ impl<'a> Ctx<'a> {
span_map: OnceCell::new(),
visibilities: FxIndexSet::default(),
top_level: Vec::new(),
+ krate,
}
}
#[inline]
pub(super) fn cfg_options(&self) -> &'a CfgOptions {
- self.cfg_options.get_or_init(|| self.file.krate(self.db).cfg_options(self.db))
+ self.cfg_options.get_or_init(|| self.krate.cfg_options(self.db))
}
pub(super) fn span_map(&self) -> SpanMapRef<'_> {