Remove two hir reexports

This commit is contained in:
Chayim Refael Friedman 2025-01-10 03:19:28 +02:00
parent cc016df54b
commit 87f7a5849c
3 changed files with 28 additions and 23 deletions

View file

@ -54,11 +54,12 @@ use hir_def::{
per_ns::PerNs, per_ns::PerNs,
resolver::{HasResolver, Resolver}, resolver::{HasResolver, Resolver},
type_ref::TypesSourceMap, type_ref::TypesSourceMap,
AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId, CrateRootModuleId, AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
DefWithBodyId, EnumId, EnumVariantId, ExternCrateId, FunctionId, GenericDefId, GenericParamId, CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
HasModule, ImplId, InTypeConstId, ItemContainerId, LifetimeParamId, LocalFieldId, Lookup, GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
MacroExpander, ModuleId, StaticId, StructId, SyntheticSyntax, TraitAliasId, TraitId, TupleId, LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId, SyntheticSyntax, TraitAliasId, TraitId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId,
UnionId,
}; };
use hir_expand::{ use hir_expand::{
attrs::collect_attrs, proc_macro::ProcMacroKind, AstId, MacroCallKind, RenderedExpandError, attrs::collect_attrs, proc_macro::ProcMacroKind, AstId, MacroCallKind, RenderedExpandError,
@ -127,7 +128,7 @@ pub use {
ImportPathConfig, ImportPathConfig,
// FIXME: This is here since some queries take it as input that are used // FIXME: This is here since some queries take it as input that are used
// outside of hir. // outside of hir.
{AdtId, MacroId, ModuleDefId}, ModuleDefId,
}, },
hir_expand::{ hir_expand::{
attrs::{Attr, AttrId}, attrs::{Attr, AttrId},
@ -3000,6 +3001,10 @@ impl Macro {
matches!(self.id, MacroId::MacroRulesId(id) if db.macro_rules_data(id).macro_export) matches!(self.id, MacroId::MacroRulesId(id) if db.macro_rules_data(id).macro_export)
} }
pub fn is_proc_macro(self) -> bool {
matches!(self.id, MacroId::ProcMacroId(_))
}
pub fn kind(&self, db: &dyn HirDatabase) -> MacroKind { pub fn kind(&self, db: &dyn HirDatabase) -> MacroKind {
match self.id { match self.id {
MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander { MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander {

View file

@ -260,23 +260,23 @@ impl From<hir::MacroKind> for SymbolKind {
} }
} }
impl From<hir::ModuleDefId> for SymbolKind { impl From<hir::ModuleDef> for SymbolKind {
fn from(it: hir::ModuleDefId) -> Self { fn from(it: hir::ModuleDef) -> Self {
match it { match it {
hir::ModuleDefId::ConstId(..) => SymbolKind::Const, hir::ModuleDef::Const(..) => SymbolKind::Const,
hir::ModuleDefId::EnumVariantId(..) => SymbolKind::Variant, hir::ModuleDef::Variant(..) => SymbolKind::Variant,
hir::ModuleDefId::FunctionId(..) => SymbolKind::Function, hir::ModuleDef::Function(..) => SymbolKind::Function,
hir::ModuleDefId::MacroId(hir::MacroId::ProcMacroId(..)) => SymbolKind::ProcMacro, hir::ModuleDef::Macro(mac) if mac.is_proc_macro() => SymbolKind::ProcMacro,
hir::ModuleDefId::MacroId(..) => SymbolKind::Macro, hir::ModuleDef::Macro(..) => SymbolKind::Macro,
hir::ModuleDefId::ModuleId(..) => SymbolKind::Module, hir::ModuleDef::Module(..) => SymbolKind::Module,
hir::ModuleDefId::StaticId(..) => SymbolKind::Static, hir::ModuleDef::Static(..) => SymbolKind::Static,
hir::ModuleDefId::AdtId(hir::AdtId::StructId(..)) => SymbolKind::Struct, hir::ModuleDef::Adt(hir::Adt::Struct(..)) => SymbolKind::Struct,
hir::ModuleDefId::AdtId(hir::AdtId::EnumId(..)) => SymbolKind::Enum, hir::ModuleDef::Adt(hir::Adt::Enum(..)) => SymbolKind::Enum,
hir::ModuleDefId::AdtId(hir::AdtId::UnionId(..)) => SymbolKind::Union, hir::ModuleDef::Adt(hir::Adt::Union(..)) => SymbolKind::Union,
hir::ModuleDefId::TraitId(..) => SymbolKind::Trait, hir::ModuleDef::Trait(..) => SymbolKind::Trait,
hir::ModuleDefId::TraitAliasId(..) => SymbolKind::TraitAlias, hir::ModuleDef::TraitAlias(..) => SymbolKind::TraitAlias,
hir::ModuleDefId::TypeAliasId(..) => SymbolKind::TypeAlias, hir::ModuleDef::TypeAlias(..) => SymbolKind::TypeAlias,
hir::ModuleDefId::BuiltinType(..) => SymbolKind::TypeAlias, hir::ModuleDef::BuiltinType(..) => SymbolKind::TypeAlias,
} }
} }
} }

View file

@ -195,7 +195,7 @@ impl TryToNav for FileSymbol {
|it| it.display_no_db(edition).to_smolstr(), |it| it.display_no_db(edition).to_smolstr(),
), ),
alias: self.is_alias.then(|| self.name.clone()), alias: self.is_alias.then(|| self.name.clone()),
kind: Some(hir::ModuleDefId::from(self.def).into()), kind: Some(self.def.into()),
full_range, full_range,
focus_range, focus_range,
container_name: self.container_name.clone(), container_name: self.container_name.clone(),