Skip to content

Commit

Permalink
Remove two hir reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
ChayimFriedman2 committed Jan 10, 2025
1 parent cc016df commit 87f7a58
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
17 changes: 11 additions & 6 deletions crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ use hir_def::{
per_ns::PerNs,
resolver::{HasResolver, Resolver},
type_ref::TypesSourceMap,
AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId, CrateRootModuleId,
DefWithBodyId, EnumId, EnumVariantId, ExternCrateId, FunctionId, GenericDefId, GenericParamId,
HasModule, ImplId, InTypeConstId, ItemContainerId, LifetimeParamId, LocalFieldId, Lookup,
MacroExpander, ModuleId, StaticId, StructId, SyntheticSyntax, TraitAliasId, TraitId, TupleId,
TypeAliasId, TypeOrConstParamId, TypeParamId, UnionId,
AdtId, AssocItemId, AssocItemLoc, AttrDefId, CallableDefId, ConstId, ConstParamId,
CrateRootModuleId, DefWithBodyId, EnumId, EnumVariantId, ExternCrateId, FunctionId,
GenericDefId, GenericParamId, HasModule, ImplId, InTypeConstId, ItemContainerId,
LifetimeParamId, LocalFieldId, Lookup, MacroExpander, MacroId, ModuleId, StaticId, StructId,
SyntheticSyntax, TraitAliasId, TraitId, TupleId, TypeAliasId, TypeOrConstParamId, TypeParamId,
UnionId,
};
use hir_expand::{
attrs::collect_attrs, proc_macro::ProcMacroKind, AstId, MacroCallKind, RenderedExpandError,
Expand Down Expand Up @@ -127,7 +128,7 @@ pub use {
ImportPathConfig,
// FIXME: This is here since some queries take it as input that are used
// outside of hir.
{AdtId, MacroId, ModuleDefId},
ModuleDefId,
},
hir_expand::{
attrs::{Attr, AttrId},
Expand Down Expand Up @@ -3000,6 +3001,10 @@ impl Macro {
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 {
match self.id {
MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander {
Expand Down
32 changes: 16 additions & 16 deletions crates/ide-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,23 @@ impl From<hir::MacroKind> for SymbolKind {
}
}

impl From<hir::ModuleDefId> for SymbolKind {
fn from(it: hir::ModuleDefId) -> Self {
impl From<hir::ModuleDef> for SymbolKind {
fn from(it: hir::ModuleDef) -> Self {
match it {
hir::ModuleDefId::ConstId(..) => SymbolKind::Const,
hir::ModuleDefId::EnumVariantId(..) => SymbolKind::Variant,
hir::ModuleDefId::FunctionId(..) => SymbolKind::Function,
hir::ModuleDefId::MacroId(hir::MacroId::ProcMacroId(..)) => SymbolKind::ProcMacro,
hir::ModuleDefId::MacroId(..) => SymbolKind::Macro,
hir::ModuleDefId::ModuleId(..) => SymbolKind::Module,
hir::ModuleDefId::StaticId(..) => SymbolKind::Static,
hir::ModuleDefId::AdtId(hir::AdtId::StructId(..)) => SymbolKind::Struct,
hir::ModuleDefId::AdtId(hir::AdtId::EnumId(..)) => SymbolKind::Enum,
hir::ModuleDefId::AdtId(hir::AdtId::UnionId(..)) => SymbolKind::Union,
hir::ModuleDefId::TraitId(..) => SymbolKind::Trait,
hir::ModuleDefId::TraitAliasId(..) => SymbolKind::TraitAlias,
hir::ModuleDefId::TypeAliasId(..) => SymbolKind::TypeAlias,
hir::ModuleDefId::BuiltinType(..) => SymbolKind::TypeAlias,
hir::ModuleDef::Const(..) => SymbolKind::Const,
hir::ModuleDef::Variant(..) => SymbolKind::Variant,
hir::ModuleDef::Function(..) => SymbolKind::Function,
hir::ModuleDef::Macro(mac) if mac.is_proc_macro() => SymbolKind::ProcMacro,
hir::ModuleDef::Macro(..) => SymbolKind::Macro,
hir::ModuleDef::Module(..) => SymbolKind::Module,
hir::ModuleDef::Static(..) => SymbolKind::Static,
hir::ModuleDef::Adt(hir::Adt::Struct(..)) => SymbolKind::Struct,
hir::ModuleDef::Adt(hir::Adt::Enum(..)) => SymbolKind::Enum,
hir::ModuleDef::Adt(hir::Adt::Union(..)) => SymbolKind::Union,
hir::ModuleDef::Trait(..) => SymbolKind::Trait,
hir::ModuleDef::TraitAlias(..) => SymbolKind::TraitAlias,
hir::ModuleDef::TypeAlias(..) => SymbolKind::TypeAlias,
hir::ModuleDef::BuiltinType(..) => SymbolKind::TypeAlias,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/navigation_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl TryToNav for FileSymbol {
|it| it.display_no_db(edition).to_smolstr(),
),
alias: self.is_alias.then(|| self.name.clone()),
kind: Some(hir::ModuleDefId::from(self.def).into()),
kind: Some(self.def.into()),
full_range,
focus_range,
container_name: self.container_name.clone(),
Expand Down

0 comments on commit 87f7a58

Please sign in to comment.