fix: formatting

This commit is contained in:
Kartavya Vashishtha 2022-08-20 13:44:01 +05:30
parent 8f87fcb179
commit 23c00ed50d
No known key found for this signature in database
GPG key ID: A50012C2324E5DF0
3 changed files with 29 additions and 12 deletions

View file

@ -2,7 +2,7 @@
use std::sync::Arc; use std::sync::Arc;
use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, MacroCallId, MacroDefKind, InFile}; use hir_expand::{name::Name, AstId, ExpandResult, HirFileId, InFile, MacroCallId, MacroDefKind};
use smallvec::SmallVec; use smallvec::SmallVec;
use syntax::ast; use syntax::ast;
@ -12,7 +12,10 @@ use crate::{
db::DefDatabase, db::DefDatabase,
intern::Interned, intern::Interned,
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId}, item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId},
nameres::{attr_resolution::ResolvedAttr, proc_macro::ProcMacroKind, DefMap, diagnostics::DefDiagnostic}, nameres::{
attr_resolution::ResolvedAttr, diagnostics::DefDiagnostic, proc_macro::ProcMacroKind,
DefMap,
},
type_ref::{TraitRef, TypeBound, TypeRef}, type_ref::{TraitRef, TypeBound, TypeRef},
visibility::RawVisibility, visibility::RawVisibility,
AssocItemId, AstIdWithPath, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId, AssocItemId, AstIdWithPath, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId,
@ -213,7 +216,10 @@ impl TraitData {
db.trait_data_with_diagnostics(tr).0 db.trait_data_with_diagnostics(tr).0
} }
pub(crate) fn trait_data_with_diagnostics_query(db: &dyn DefDatabase, tr: TraitId) -> (Arc<TraitData>, Arc<Vec<DefDiagnostic>>) { pub(crate) fn trait_data_with_diagnostics_query(
db: &dyn DefDatabase,
tr: TraitId,
) -> (Arc<TraitData>, Arc<Vec<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];
@ -245,7 +251,7 @@ impl TraitData {
visibility, visibility,
skip_array_during_method_dispatch, skip_array_during_method_dispatch,
}), }),
Arc::new(diagnostics) Arc::new(diagnostics),
) )
} }
@ -290,7 +296,10 @@ impl ImplData {
db.impl_data_with_diagnostics(id).0 db.impl_data_with_diagnostics(id).0
} }
pub(crate) fn impl_data_with_diagnostics_query(db: &dyn DefDatabase, id: ImplId) -> (Arc<ImplData>, Arc<Vec<DefDiagnostic>>) { pub(crate) fn impl_data_with_diagnostics_query(
db: &dyn DefDatabase,
id: ImplId,
) -> (Arc<ImplData>, Arc<Vec<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);
@ -307,7 +316,10 @@ impl ImplData {
let (items, attribute_calls, diagnostics) = collector.finish(); let (items, attribute_calls, diagnostics) = collector.finish();
let items = items.into_iter().map(|(_, item)| item).collect(); let items = items.into_iter().map(|(_, item)| item).collect();
(Arc::new(ImplData { target_trait, self_ty, items, is_negative, attribute_calls }), Arc::new(diagnostics)) (
Arc::new(ImplData { target_trait, self_ty, items, is_negative, attribute_calls }),
Arc::new(diagnostics),
)
} }
pub fn attribute_calls(&self) -> impl Iterator<Item = (AstId<ast::Item>, MacroCallId)> + '_ { pub fn attribute_calls(&self) -> impl Iterator<Item = (AstId<ast::Item>, MacroCallId)> + '_ {
@ -477,11 +489,15 @@ impl<'a> AssocItemCollector<'a> {
fn finish( fn finish(
self, self,
) -> (Vec<(Name, AssocItemId)>, Option<Box<Vec<(AstId<ast::Item>, MacroCallId)>>>, Vec<DefDiagnostic>) { ) -> (
Vec<(Name, AssocItemId)>,
Option<Box<Vec<(AstId<ast::Item>, MacroCallId)>>>,
Vec<DefDiagnostic>,
) {
( (
self.items, self.items,
if self.attr_calls.is_empty() { None } else { Some(Box::new(self.attr_calls)) }, if self.attr_calls.is_empty() { None } else { Some(Box::new(self.attr_calls)) },
self.inactive_diagnostics self.inactive_diagnostics,
) )
} }
@ -497,7 +513,7 @@ impl<'a> AssocItemCollector<'a> {
self.module_id.local_id, self.module_id.local_id,
InFile::new(self.expander.current_file_id(), item.ast_id(&item_tree).upcast()), InFile::new(self.expander.current_file_id(), item.ast_id(&item_tree).upcast()),
attrs.cfg().unwrap(), attrs.cfg().unwrap(),
self.expander.cfg_options().clone() self.expander.cfg_options().clone(),
)); ));
continue; continue;
} }

View file

@ -20,7 +20,7 @@ use crate::{
intern::Interned, intern::Interned,
item_tree::{AttrOwner, ItemTree}, item_tree::{AttrOwner, ItemTree},
lang_item::{LangItemTarget, LangItems}, lang_item::{LangItemTarget, LangItems},
nameres::{DefMap, diagnostics::DefDiagnostic}, nameres::{diagnostics::DefDiagnostic, DefMap},
visibility::{self, Visibility}, visibility::{self, Visibility},
AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, ExternBlockId, AttrDefId, BlockId, BlockLoc, ConstId, ConstLoc, DefWithBodyId, EnumId, EnumLoc, ExternBlockId,
ExternBlockLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalEnumVariantId, ExternBlockLoc, FunctionId, FunctionLoc, GenericDefId, ImplId, ImplLoc, LocalEnumVariantId,
@ -113,7 +113,8 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
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) -> (Arc<TraitData>, Arc<Vec<DefDiagnostic>>); fn trait_data_with_diagnostics(&self, tr: TraitId)
-> (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>;

View file

@ -531,7 +531,7 @@ impl Module {
if def_map[m.id.local_id].origin.is_inline() { if def_map[m.id.local_id].origin.is_inline() {
m.diagnostics(db, acc) m.diagnostics(db, acc)
} }
}, }
ModuleDef::Trait(t) => { ModuleDef::Trait(t) => {
for diag in db.trait_data_with_diagnostics(t.id).1.iter() { for diag in db.trait_data_with_diagnostics(t.id).1.iter() {
emit_def_diagnostic(db, acc, diag); emit_def_diagnostic(db, acc, diag);