Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: Remove two hir reexports #18901

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading