Skip to content

Commit 2b4c2c3

Browse files
authored
Merge pull request rust-lang#22745 from ada4a/unquerygroup-defdatabase
internal: remove `DefDatabase`
2 parents e8fb38f + ae6d2e9 commit 2b4c2c3

52 files changed

Lines changed: 690 additions & 741 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/hir-def/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ triomphe.workspace = true
2929
rustc_apfloat = "0.2.3"
3030
salsa.workspace = true
3131
salsa-macros.workspace = true
32-
query-group.workspace = true
3332

3433
ra-ap-rustc_parse_format.workspace = true
3534
ra-ap-rustc_abi.workspace = true

crates/hir-def/src/attrs.rs

Lines changed: 54 additions & 44 deletions
Large diffs are not rendered by default.

crates/hir-def/src/attrs/docs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
ops::{ControlFlow, Range},
1212
};
1313

14-
use base_db::Crate;
14+
use base_db::{Crate, SourceDatabase};
1515
use cfg::CfgOptions;
1616
use either::Either;
1717
use hir_expand::{
@@ -27,7 +27,7 @@ use syntax::{
2727
};
2828
use tt::{TextRange, TextSize};
2929

30-
use crate::{db::DefDatabase, macro_call_as_call_id, nameres::MacroSubNs, resolver::Resolver};
30+
use crate::{macro_call_as_call_id, nameres::MacroSubNs, resolver::Resolver};
3131

3232
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3333
pub(crate) struct DocsSourceMapLine {
@@ -323,7 +323,7 @@ impl Docs {
323323
}
324324

325325
struct DocMacroExpander<'db> {
326-
db: &'db dyn DefDatabase,
326+
db: &'db dyn SourceDatabase,
327327
krate: Crate,
328328
recursion_depth: usize,
329329
recursion_limit: usize,
@@ -408,7 +408,7 @@ fn expand_doc_macro_call<'db>(
408408

409409
fn extend_with_attrs<'a, 'db>(
410410
result: &mut Docs,
411-
db: &'db dyn DefDatabase,
411+
db: &'db dyn SourceDatabase,
412412
krate: Crate,
413413
node: &SyntaxNode,
414414
file_id: HirFileId,
@@ -473,7 +473,7 @@ fn extend_with_attrs<'a, 'db>(
473473
}
474474

475475
pub(crate) fn extract_docs<'a, 'db>(
476-
db: &'db dyn DefDatabase,
476+
db: &'db dyn SourceDatabase,
477477
krate: Crate,
478478
resolver: &dyn Fn() -> Resolver<'db>,
479479
get_cfg_options: &dyn Fn() -> &'a CfgOptions,

crates/hir-def/src/builtin_derive.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
//! To save time and memory, builtin derives are not really expanded. Instead, we record them
44
//! and create their impls based on lowered data, see crates/hir-ty/src/builtin_derive.rs.
55
6+
use base_db::SourceDatabase;
67
use hir_expand::{InFile, builtin::BuiltinDeriveExpander, name::Name};
78
use intern::{Symbol, sym};
89
use tt::TextRange;
910

1011
use crate::{
1112
AdtId, BuiltinDeriveImplId, BuiltinDeriveImplLoc, FunctionId, HasModule, MacroId,
12-
db::DefDatabase, lang_item::LangItems,
13+
lang_item::LangItems,
1314
};
1415

1516
macro_rules! declare_enum {
@@ -109,7 +110,7 @@ impl BuiltinDeriveImplTrait {
109110
impl BuiltinDeriveImplMethod {
110111
pub fn trait_method(
111112
self,
112-
db: &dyn DefDatabase,
113+
db: &dyn SourceDatabase,
113114
impl_: BuiltinDeriveImplId,
114115
) -> Option<FunctionId> {
115116
let loc = impl_.loc(db);
@@ -143,7 +144,7 @@ pub(crate) fn with_derive_traits(
143144
}
144145

145146
impl BuiltinDeriveImplLoc {
146-
pub fn source(&self, db: &dyn DefDatabase) -> InFile<TextRange> {
147+
pub fn source(&self, db: &dyn SourceDatabase) -> InFile<TextRange> {
147148
let (adt_ast_id, module) = match self.adt {
148149
AdtId::StructId(adt) => {
149150
let adt_loc = adt.loc(db);

crates/hir-def/src/db.rs

Lines changed: 0 additions & 135 deletions
This file was deleted.

crates/hir-def/src/expr_store.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{
1414
ops::{Deref, Index},
1515
};
1616

17+
use base_db::SourceDatabase;
1718
use cfg::{CfgExpr, CfgOptions};
1819
use either::Either;
1920
use hir_expand::{InFile, MacroCallId, mod_path::ModPath, name::Name};
@@ -27,7 +28,6 @@ use tt::TextRange;
2728

2829
use crate::{
2930
AdtId, BlockId, ExpressionStoreOwnerId, GenericDefId, SyntheticSyntax,
30-
db::DefDatabase,
3131
expr_store::path::{AssociatedTypeBinding, GenericArg, GenericArgs, NormalPath, Path},
3232
hir::{
3333
Array, AsmOperand, Binding, BindingId, Expr, ExprId, ExprOrPatId, InlineAsm, Label,
@@ -466,7 +466,7 @@ impl ExpressionStore {
466466
ExpressionStore::EMPTY
467467
}
468468

469-
pub fn of(db: &dyn DefDatabase, def: ExpressionStoreOwnerId) -> &ExpressionStore {
469+
pub fn of(db: &dyn SourceDatabase, def: ExpressionStoreOwnerId) -> &ExpressionStore {
470470
match def {
471471
ExpressionStoreOwnerId::Signature(def) => {
472472
use crate::signatures::{
@@ -494,7 +494,7 @@ impl ExpressionStore {
494494
}
495495

496496
pub fn with_source_map(
497-
db: &dyn DefDatabase,
497+
db: &dyn SourceDatabase,
498498
def: ExpressionStoreOwnerId,
499499
) -> (&ExpressionStore, &ExpressionStoreSourceMap) {
500500
match def {
@@ -589,7 +589,7 @@ impl ExpressionStore {
589589
/// Returns an iterator over all block expressions in this store that define inner items.
590590
pub fn blocks<'a>(
591591
&'a self,
592-
db: &'a dyn DefDatabase,
592+
db: &'a dyn SourceDatabase,
593593
) -> impl Iterator<Item = (BlockId, &'a DefMap)> + 'a {
594594
self.expr_only
595595
.as_ref()

crates/hir-def/src/expr_store/body.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//! consts.
33
use std::ops;
44

5+
use base_db::SourceDatabase;
56
use hir_expand::{InFile, Lookup};
67
use span::Edition;
78
use syntax::ast;
89
use triomphe::Arc;
910

1011
use crate::{
1112
DefWithBodyId, ExpressionStoreOwnerId, HasModule,
12-
db::DefDatabase,
1313
expr_store::{
1414
ExpressionStore, ExpressionStoreSourceMap, SelfParamPtr, lower::lower_body, pretty,
1515
},
@@ -87,7 +87,10 @@ impl ops::Deref for BodySourceMap {
8787
#[salsa::tracked]
8888
impl Body {
8989
#[salsa::tracked(lru = 512, returns(ref))]
90-
pub fn with_source_map(db: &dyn DefDatabase, def: DefWithBodyId) -> (Arc<Body>, BodySourceMap) {
90+
pub fn with_source_map(
91+
db: &dyn SourceDatabase,
92+
def: DefWithBodyId,
93+
) -> (Arc<Body>, BodySourceMap) {
9194
let _p = tracing::info_span!("body_with_source_map_query").entered();
9295
let mut params = None;
9396

@@ -128,7 +131,7 @@ impl Body {
128131
}
129132

130133
#[salsa::tracked(returns(deref))]
131-
pub fn of(db: &dyn DefDatabase, def: DefWithBodyId) -> Arc<Body> {
134+
pub fn of(db: &dyn SourceDatabase, def: DefWithBodyId) -> Arc<Body> {
132135
Self::with_source_map(db, def).0.clone()
133136
}
134137
}
@@ -150,7 +153,7 @@ impl Body {
150153

151154
pub fn pretty_print(
152155
&self,
153-
db: &dyn DefDatabase,
156+
db: &dyn SourceDatabase,
154157
owner: DefWithBodyId,
155158
edition: Edition,
156159
) -> String {
@@ -159,7 +162,7 @@ impl Body {
159162

160163
pub fn pretty_print_expr(
161164
&self,
162-
db: &dyn DefDatabase,
165+
db: &dyn SourceDatabase,
163166
owner: DefWithBodyId,
164167
expr: ExprId,
165168
edition: Edition,
@@ -169,7 +172,7 @@ impl Body {
169172

170173
pub fn pretty_print_pat(
171174
&self,
172-
db: &dyn DefDatabase,
175+
db: &dyn SourceDatabase,
173176
owner: ExpressionStoreOwnerId,
174177
pat: PatId,
175178
oneline: bool,

0 commit comments

Comments
 (0)