remove useless aliases
This commit is contained in:
parent
a7c0336a75
commit
11dda8a0fb
@ -13,7 +13,7 @@ use crate::{
|
||||
HirDatabase, DefKind,
|
||||
SourceItemId,
|
||||
type_ref::TypeRef,
|
||||
ids::{StructLoc, EnumLoc},
|
||||
ids::ItemLoc,
|
||||
};
|
||||
|
||||
impl Struct {
|
||||
@ -23,8 +23,8 @@ impl Struct {
|
||||
file_id: HirFileId,
|
||||
ast: &ast::StructDef,
|
||||
) -> Struct {
|
||||
let loc: StructLoc = StructLoc::from_ast(db, module, file_id, ast);
|
||||
let id = loc.id(db);
|
||||
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||
let id = db.as_ref().structs.loc2id(&loc);
|
||||
Struct { id }
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ impl Enum {
|
||||
file_id: HirFileId,
|
||||
ast: &ast::EnumDef,
|
||||
) -> Enum {
|
||||
let loc: EnumLoc = EnumLoc::from_ast(db, module, file_id, ast);
|
||||
let id = loc.id(db);
|
||||
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||
let id = db.as_ref().enums.loc2id(&loc);
|
||||
Enum { id }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
type_ref::{TypeRef, Mutability},
|
||||
expr::Body,
|
||||
impl_block::ImplBlock,
|
||||
ids::FunctionLoc,
|
||||
ids::ItemLoc,
|
||||
};
|
||||
|
||||
pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
|
||||
@ -21,8 +21,8 @@ impl Function {
|
||||
file_id: HirFileId,
|
||||
ast: &ast::FnDef,
|
||||
) -> Function {
|
||||
let loc: FunctionLoc = FunctionLoc::from_ast(db, module, file_id, ast);
|
||||
let id = loc.id(db);
|
||||
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||
let id = db.as_ref().fns.loc2id(&loc);
|
||||
Function { id }
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,9 @@ use crate::{
|
||||
pub struct HirInterner {
|
||||
defs: LocationIntener<DefLoc, DefId>,
|
||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||
fns: LocationIntener<FunctionLoc, FunctionId>,
|
||||
structs: LocationIntener<StructLoc, StructId>,
|
||||
enums: LocationIntener<EnumLoc, EnumId>,
|
||||
pub(crate) fns: LocationIntener<ItemLoc<ast::FnDef>, FunctionId>,
|
||||
pub(crate) structs: LocationIntener<ItemLoc<ast::StructDef>, StructId>,
|
||||
pub(crate) enums: LocationIntener<ItemLoc<ast::EnumDef>, EnumId>,
|
||||
}
|
||||
|
||||
impl HirInterner {
|
||||
@ -182,56 +182,32 @@ impl<N: AstNode> Clone for ItemLoc<N> {
|
||||
pub struct FunctionId(RawId);
|
||||
impl_arena_id!(FunctionId);
|
||||
|
||||
pub(crate) type FunctionLoc = ItemLoc<ast::FnDef>;
|
||||
|
||||
impl FunctionId {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> FunctionLoc {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::FnDef> {
|
||||
db.as_ref().fns.id2loc(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl FunctionLoc {
|
||||
pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> FunctionId {
|
||||
db.as_ref().fns.loc2id(&self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct StructId(RawId);
|
||||
impl_arena_id!(StructId);
|
||||
|
||||
pub(crate) type StructLoc = ItemLoc<ast::StructDef>;
|
||||
|
||||
impl StructId {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> StructLoc {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::StructDef> {
|
||||
db.as_ref().structs.id2loc(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl StructLoc {
|
||||
pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> StructId {
|
||||
db.as_ref().structs.loc2id(&self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct EnumId(RawId);
|
||||
impl_arena_id!(EnumId);
|
||||
|
||||
pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>;
|
||||
|
||||
impl EnumId {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> EnumLoc {
|
||||
pub(crate) fn loc(self, db: &impl AsRef<HirInterner>) -> ItemLoc<ast::EnumDef> {
|
||||
db.as_ref().enums.id2loc(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl EnumLoc {
|
||||
pub(crate) fn id(&self, db: &impl AsRef<HirInterner>) -> EnumId {
|
||||
db.as_ref().enums.loc2id(&self)
|
||||
}
|
||||
}
|
||||
|
||||
/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc)
|
||||
/// in a specific module.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user