mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
internal: Make data queries transparent over their diagnostics variant
This commit is contained in:
parent
90a1b484f7
commit
54f2111f69
6 changed files with 21 additions and 26 deletions
|
@ -233,6 +233,7 @@ pub struct TraitData {
|
|||
}
|
||||
|
||||
impl TraitData {
|
||||
#[inline]
|
||||
pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
|
||||
db.trait_data_with_diagnostics(tr).0
|
||||
}
|
||||
|
@ -241,12 +242,9 @@ impl TraitData {
|
|||
db: &dyn DefDatabase,
|
||||
tr: TraitId,
|
||||
) -> (Arc<TraitData>, DefDiagnostics) {
|
||||
let tr_loc @ ItemLoc { container: module_id, id: tree_id } = tr.lookup(db);
|
||||
let ItemLoc { container: module_id, id: tree_id } = tr.lookup(db);
|
||||
let item_tree = tree_id.item_tree(db);
|
||||
let tr_def = &item_tree[tree_id.value];
|
||||
let _cx = stdx::panic_context::enter(format!(
|
||||
"trait_data_query({tr:?} -> {tr_loc:?} -> {tr_def:?})"
|
||||
));
|
||||
let name = tr_def.name.clone();
|
||||
let is_auto = tr_def.is_auto;
|
||||
let is_unsafe = tr_def.is_unsafe;
|
||||
|
@ -333,6 +331,7 @@ pub struct ImplData {
|
|||
}
|
||||
|
||||
impl ImplData {
|
||||
#[inline]
|
||||
pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> {
|
||||
db.impl_data_with_diagnostics(id).0
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ fn parse_repr_tt(tt: &Subtree) -> Option<ReprOptions> {
|
|||
}
|
||||
|
||||
impl StructData {
|
||||
#[inline]
|
||||
pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc<StructData> {
|
||||
db.struct_data_with_diagnostics(id).0
|
||||
}
|
||||
|
@ -236,6 +237,7 @@ impl StructData {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc<StructData> {
|
||||
db.union_data_with_diagnostics(id).0
|
||||
}
|
||||
|
@ -322,6 +324,7 @@ impl EnumData {
|
|||
}
|
||||
|
||||
impl EnumVariantData {
|
||||
#[inline]
|
||||
pub(crate) fn enum_variant_data_query(
|
||||
db: &dyn DefDatabase,
|
||||
e: EnumVariantId,
|
||||
|
|
|
@ -117,12 +117,14 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
|
|||
|
||||
// region:data
|
||||
|
||||
#[salsa::transparent]
|
||||
#[salsa::invoke(StructData::struct_data_query)]
|
||||
fn struct_data(&self, id: StructId) -> Arc<StructData>;
|
||||
|
||||
#[salsa::invoke(StructData::struct_data_with_diagnostics_query)]
|
||||
fn struct_data_with_diagnostics(&self, id: StructId) -> (Arc<StructData>, DefDiagnostics);
|
||||
|
||||
#[salsa::transparent]
|
||||
#[salsa::invoke(StructData::union_data_query)]
|
||||
fn union_data(&self, id: UnionId) -> Arc<StructData>;
|
||||
|
||||
|
@ -132,6 +134,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
|
|||
#[salsa::invoke(EnumData::enum_data_query)]
|
||||
fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
|
||||
|
||||
#[salsa::transparent]
|
||||
#[salsa::invoke(EnumVariantData::enum_variant_data_query)]
|
||||
fn enum_variant_data(&self, id: EnumVariantId) -> Arc<EnumVariantData>;
|
||||
|
||||
|
@ -141,12 +144,14 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
|
|||
id: EnumVariantId,
|
||||
) -> (Arc<EnumVariantData>, DefDiagnostics);
|
||||
|
||||
#[salsa::transparent]
|
||||
#[salsa::invoke(ImplData::impl_data_query)]
|
||||
fn impl_data(&self, e: ImplId) -> Arc<ImplData>;
|
||||
|
||||
#[salsa::invoke(ImplData::impl_data_with_diagnostics_query)]
|
||||
fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, DefDiagnostics);
|
||||
|
||||
#[salsa::transparent]
|
||||
#[salsa::invoke(TraitData::trait_data_query)]
|
||||
fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
|
||||
|
||||
|
|
|
@ -6,20 +6,18 @@
|
|||
pub use hir_def::db::{
|
||||
AttrsQuery, BlockDefMapQuery, BlockItemTreeQueryQuery, BodyQuery, BodyWithSourceMapQuery,
|
||||
ConstDataQuery, ConstVisibilityQuery, CrateDefMapQueryQuery, CrateLangItemsQuery,
|
||||
CrateSupportsNoStdQuery, DefDatabase, DefDatabaseStorage, EnumDataQuery, EnumVariantDataQuery,
|
||||
CrateSupportsNoStdQuery, DefDatabase, DefDatabaseStorage, EnumDataQuery,
|
||||
EnumVariantDataWithDiagnosticsQuery, ExprScopesQuery, ExternCrateDeclDataQuery,
|
||||
FieldVisibilitiesQuery, FieldsAttrsQuery, FieldsAttrsSourceMapQuery, FileItemTreeQuery,
|
||||
FunctionDataQuery, FunctionVisibilityQuery, GenericParamsQuery, ImplDataQuery,
|
||||
ImplDataWithDiagnosticsQuery, ImportMapQuery, InternAnonymousConstQuery, InternBlockQuery,
|
||||
InternConstQuery, InternDatabase, InternDatabaseStorage, InternEnumQuery,
|
||||
InternExternBlockQuery, InternExternCrateQuery, InternFunctionQuery, InternImplQuery,
|
||||
InternInTypeConstQuery, InternMacro2Query, InternMacroRulesQuery, InternProcMacroQuery,
|
||||
InternStaticQuery, InternStructQuery, InternTraitAliasQuery, InternTraitQuery,
|
||||
InternTypeAliasQuery, InternUnionQuery, InternUseQuery, LangItemQuery, Macro2DataQuery,
|
||||
MacroRulesDataQuery, ProcMacroDataQuery, StaticDataQuery, StructDataQuery,
|
||||
StructDataWithDiagnosticsQuery, TraitAliasDataQuery, TraitDataQuery,
|
||||
TraitDataWithDiagnosticsQuery, TypeAliasDataQuery, UnionDataQuery,
|
||||
UnionDataWithDiagnosticsQuery,
|
||||
FunctionDataQuery, FunctionVisibilityQuery, GenericParamsQuery, ImplDataWithDiagnosticsQuery,
|
||||
ImportMapQuery, InternAnonymousConstQuery, InternBlockQuery, InternConstQuery, InternDatabase,
|
||||
InternDatabaseStorage, InternEnumQuery, InternExternBlockQuery, InternExternCrateQuery,
|
||||
InternFunctionQuery, InternImplQuery, InternInTypeConstQuery, InternMacro2Query,
|
||||
InternMacroRulesQuery, InternProcMacroQuery, InternStaticQuery, InternStructQuery,
|
||||
InternTraitAliasQuery, InternTraitQuery, InternTypeAliasQuery, InternUnionQuery,
|
||||
InternUseQuery, LangItemQuery, Macro2DataQuery, MacroRulesDataQuery, ProcMacroDataQuery,
|
||||
StaticDataQuery, StructDataWithDiagnosticsQuery, TraitAliasDataQuery,
|
||||
TraitDataWithDiagnosticsQuery, TypeAliasDataQuery, UnionDataWithDiagnosticsQuery,
|
||||
};
|
||||
pub use hir_expand::db::{
|
||||
AstIdMapQuery, DeclMacroExpanderQuery, ExpandDatabase, ExpandDatabaseStorage,
|
||||
|
|
|
@ -136,16 +136,11 @@ impl RootDatabase {
|
|||
hir::db::FileItemTreeQuery
|
||||
hir::db::CrateDefMapQueryQuery
|
||||
hir::db::BlockDefMapQuery
|
||||
hir::db::StructDataQuery
|
||||
hir::db::StructDataWithDiagnosticsQuery
|
||||
hir::db::UnionDataQuery
|
||||
hir::db::UnionDataWithDiagnosticsQuery
|
||||
hir::db::EnumDataQuery
|
||||
hir::db::EnumVariantDataWithDiagnosticsQuery
|
||||
hir::db::EnumVariantDataQuery
|
||||
hir::db::ImplDataQuery
|
||||
hir::db::ImplDataWithDiagnosticsQuery
|
||||
hir::db::TraitDataQuery
|
||||
hir::db::TraitDataWithDiagnosticsQuery
|
||||
hir::db::TraitAliasDataQuery
|
||||
hir::db::TypeAliasDataQuery
|
||||
|
|
|
@ -217,16 +217,11 @@ impl RootDatabase {
|
|||
hir_db::FileItemTreeQuery
|
||||
hir_db::CrateDefMapQueryQuery
|
||||
hir_db::BlockDefMapQuery
|
||||
hir_db::StructDataQuery
|
||||
hir_db::StructDataWithDiagnosticsQuery
|
||||
hir_db::UnionDataQuery
|
||||
hir_db::UnionDataWithDiagnosticsQuery
|
||||
hir_db::EnumDataQuery
|
||||
hir_db::EnumDataQuery
|
||||
hir_db::EnumVariantDataWithDiagnosticsQuery
|
||||
hir_db::ImplDataQuery
|
||||
hir_db::ImplDataWithDiagnosticsQuery
|
||||
hir_db::TraitDataQuery
|
||||
hir_db::TraitDataWithDiagnosticsQuery
|
||||
hir_db::TraitAliasDataQuery
|
||||
hir_db::TypeAliasDataQuery
|
||||
|
|
Loading…
Reference in a new issue