Use Arc<[DefDiagnostic]> instead of Arc<Vec<DefDiagnostic>>

This commit is contained in:
unexge 2022-09-26 19:16:02 +01:00
parent b21bf25a07
commit 3a8d84b4a3
3 changed files with 16 additions and 22 deletions

View File

@ -151,7 +151,7 @@ pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc<Struc
pub(crate) fn struct_data_with_diagnostics_query( pub(crate) fn struct_data_with_diagnostics_query(
db: &dyn DefDatabase, db: &dyn DefDatabase,
id: StructId, id: StructId,
) -> (Arc<StructData>, Arc<Vec<DefDiagnostic>>) { ) -> (Arc<StructData>, Arc<[DefDiagnostic]>) {
let loc = id.lookup(db); let loc = id.lookup(db);
let krate = loc.container.krate; let krate = loc.container.krate;
let item_tree = loc.id.item_tree(db); let item_tree = loc.id.item_tree(db);
@ -176,7 +176,7 @@ pub(crate) fn struct_data_with_diagnostics_query(
repr, repr,
visibility: item_tree[strukt.visibility].clone(), visibility: item_tree[strukt.visibility].clone(),
}), }),
Arc::new(diagnostics), diagnostics.into(),
) )
} }
@ -187,7 +187,7 @@ pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc<StructD
pub(crate) fn union_data_with_diagnostics_query( pub(crate) fn union_data_with_diagnostics_query(
db: &dyn DefDatabase, db: &dyn DefDatabase,
id: UnionId, id: UnionId,
) -> (Arc<StructData>, Arc<Vec<DefDiagnostic>>) { ) -> (Arc<StructData>, Arc<[DefDiagnostic]>) {
let loc = id.lookup(db); let loc = id.lookup(db);
let krate = loc.container.krate; let krate = loc.container.krate;
let item_tree = loc.id.item_tree(db); let item_tree = loc.id.item_tree(db);
@ -212,7 +212,7 @@ pub(crate) fn union_data_with_diagnostics_query(
repr, repr,
visibility: item_tree[union.visibility].clone(), visibility: item_tree[union.visibility].clone(),
}), }),
Arc::new(diagnostics), diagnostics.into(),
) )
} }
} }
@ -225,7 +225,7 @@ pub(crate) fn enum_data_query(db: &dyn DefDatabase, e: EnumId) -> Arc<EnumData>
pub(crate) fn enum_data_with_diagnostics_query( pub(crate) fn enum_data_with_diagnostics_query(
db: &dyn DefDatabase, db: &dyn DefDatabase,
e: EnumId, e: EnumId,
) -> (Arc<EnumData>, Arc<Vec<DefDiagnostic>>) { ) -> (Arc<EnumData>, Arc<[DefDiagnostic]>) {
let loc = e.lookup(db); let loc = e.lookup(db);
let krate = loc.container.krate; let krate = loc.container.krate;
let item_tree = loc.id.item_tree(db); let item_tree = loc.id.item_tree(db);
@ -272,7 +272,7 @@ pub(crate) fn enum_data_with_diagnostics_query(
repr, repr,
visibility: item_tree[enum_.visibility].clone(), visibility: item_tree[enum_.visibility].clone(),
}), }),
Arc::new(diagnostics), diagnostics.into(),
) )
} }

View File

@ -219,7 +219,7 @@ pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitDa
pub(crate) fn trait_data_with_diagnostics_query( pub(crate) fn trait_data_with_diagnostics_query(
db: &dyn DefDatabase, db: &dyn DefDatabase,
tr: TraitId, tr: TraitId,
) -> (Arc<TraitData>, Arc<Vec<DefDiagnostic>>) { ) -> (Arc<TraitData>, Arc<[DefDiagnostic]>) {
let tr_loc @ ItemLoc { container: module_id, id: tree_id } = tr.lookup(db); let tr_loc @ ItemLoc { container: module_id, id: tree_id } = tr.lookup(db);
let item_tree = tree_id.item_tree(db); let item_tree = tree_id.item_tree(db);
let tr_def = &item_tree[tree_id.value]; let tr_def = &item_tree[tree_id.value];
@ -251,7 +251,7 @@ pub(crate) fn trait_data_with_diagnostics_query(
visibility, visibility,
skip_array_during_method_dispatch, skip_array_during_method_dispatch,
}), }),
Arc::new(diagnostics), diagnostics.into(),
) )
} }
@ -299,7 +299,7 @@ pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData>
pub(crate) fn impl_data_with_diagnostics_query( pub(crate) fn impl_data_with_diagnostics_query(
db: &dyn DefDatabase, db: &dyn DefDatabase,
id: ImplId, id: ImplId,
) -> (Arc<ImplData>, Arc<Vec<DefDiagnostic>>) { ) -> (Arc<ImplData>, Arc<[DefDiagnostic]>) {
let _p = profile::span("impl_data_with_diagnostics_query"); let _p = profile::span("impl_data_with_diagnostics_query");
let ItemLoc { container: module_id, id: tree_id } = id.lookup(db); let ItemLoc { container: module_id, id: tree_id } = id.lookup(db);
@ -318,7 +318,7 @@ pub(crate) fn impl_data_with_diagnostics_query(
( (
Arc::new(ImplData { target_trait, self_ty, items, is_negative, attribute_calls }), Arc::new(ImplData { target_trait, self_ty, items, is_negative, attribute_calls }),
Arc::new(diagnostics), diagnostics.into(),
) )
} }

View File

@ -98,38 +98,32 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
fn struct_data(&self, id: StructId) -> Arc<StructData>; fn struct_data(&self, id: StructId) -> Arc<StructData>;
#[salsa::invoke(StructData::struct_data_with_diagnostics_query)] #[salsa::invoke(StructData::struct_data_with_diagnostics_query)]
fn struct_data_with_diagnostics( fn struct_data_with_diagnostics(&self, id: StructId)
&self, -> (Arc<StructData>, Arc<[DefDiagnostic]>);
id: StructId,
) -> (Arc<StructData>, Arc<Vec<DefDiagnostic>>);
#[salsa::invoke(StructData::union_data_query)] #[salsa::invoke(StructData::union_data_query)]
fn union_data(&self, id: UnionId) -> Arc<StructData>; fn union_data(&self, id: UnionId) -> Arc<StructData>;
#[salsa::invoke(StructData::union_data_with_diagnostics_query)] #[salsa::invoke(StructData::union_data_with_diagnostics_query)]
fn union_data_with_diagnostics( fn union_data_with_diagnostics(&self, id: UnionId) -> (Arc<StructData>, Arc<[DefDiagnostic]>);
&self,
id: UnionId,
) -> (Arc<StructData>, Arc<Vec<DefDiagnostic>>);
#[salsa::invoke(EnumData::enum_data_query)] #[salsa::invoke(EnumData::enum_data_query)]
fn enum_data(&self, e: EnumId) -> Arc<EnumData>; fn enum_data(&self, e: EnumId) -> Arc<EnumData>;
#[salsa::invoke(EnumData::enum_data_with_diagnostics_query)] #[salsa::invoke(EnumData::enum_data_with_diagnostics_query)]
fn enum_data_with_diagnostics(&self, e: EnumId) -> (Arc<EnumData>, Arc<Vec<DefDiagnostic>>); fn enum_data_with_diagnostics(&self, e: EnumId) -> (Arc<EnumData>, Arc<[DefDiagnostic]>);
#[salsa::invoke(ImplData::impl_data_query)] #[salsa::invoke(ImplData::impl_data_query)]
fn impl_data(&self, e: ImplId) -> Arc<ImplData>; fn impl_data(&self, e: ImplId) -> Arc<ImplData>;
#[salsa::invoke(ImplData::impl_data_with_diagnostics_query)] #[salsa::invoke(ImplData::impl_data_with_diagnostics_query)]
fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, Arc<Vec<DefDiagnostic>>); fn impl_data_with_diagnostics(&self, e: ImplId) -> (Arc<ImplData>, Arc<[DefDiagnostic]>);
#[salsa::invoke(TraitData::trait_data_query)] #[salsa::invoke(TraitData::trait_data_query)]
fn trait_data(&self, e: TraitId) -> Arc<TraitData>; fn trait_data(&self, e: TraitId) -> Arc<TraitData>;
#[salsa::invoke(TraitData::trait_data_with_diagnostics_query)] #[salsa::invoke(TraitData::trait_data_with_diagnostics_query)]
fn trait_data_with_diagnostics(&self, tr: TraitId) fn trait_data_with_diagnostics(&self, tr: TraitId) -> (Arc<TraitData>, Arc<[DefDiagnostic]>);
-> (Arc<TraitData>, Arc<Vec<DefDiagnostic>>);
#[salsa::invoke(TypeAliasData::type_alias_data_query)] #[salsa::invoke(TypeAliasData::type_alias_data_query)]
fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>; fn type_alias_data(&self, e: TypeAliasId) -> Arc<TypeAliasData>;