mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
remove useless aliases
This commit is contained in:
parent
a7c0336a75
commit
11dda8a0fb
3 changed files with 14 additions and 38 deletions
|
@ -13,7 +13,7 @@ use crate::{
|
||||||
HirDatabase, DefKind,
|
HirDatabase, DefKind,
|
||||||
SourceItemId,
|
SourceItemId,
|
||||||
type_ref::TypeRef,
|
type_ref::TypeRef,
|
||||||
ids::{StructLoc, EnumLoc},
|
ids::ItemLoc,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Struct {
|
impl Struct {
|
||||||
|
@ -23,8 +23,8 @@ impl Struct {
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
ast: &ast::StructDef,
|
ast: &ast::StructDef,
|
||||||
) -> Struct {
|
) -> Struct {
|
||||||
let loc: StructLoc = StructLoc::from_ast(db, module, file_id, ast);
|
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||||
let id = loc.id(db);
|
let id = db.as_ref().structs.loc2id(&loc);
|
||||||
Struct { id }
|
Struct { id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ impl Enum {
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
ast: &ast::EnumDef,
|
ast: &ast::EnumDef,
|
||||||
) -> Enum {
|
) -> Enum {
|
||||||
let loc: EnumLoc = EnumLoc::from_ast(db, module, file_id, ast);
|
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||||
let id = loc.id(db);
|
let id = db.as_ref().enums.loc2id(&loc);
|
||||||
Enum { id }
|
Enum { id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
type_ref::{TypeRef, Mutability},
|
type_ref::{TypeRef, Mutability},
|
||||||
expr::Body,
|
expr::Body,
|
||||||
impl_block::ImplBlock,
|
impl_block::ImplBlock,
|
||||||
ids::FunctionLoc,
|
ids::ItemLoc,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
|
pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
|
||||||
|
@ -21,8 +21,8 @@ impl Function {
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
ast: &ast::FnDef,
|
ast: &ast::FnDef,
|
||||||
) -> Function {
|
) -> Function {
|
||||||
let loc: FunctionLoc = FunctionLoc::from_ast(db, module, file_id, ast);
|
let loc = ItemLoc::from_ast(db, module, file_id, ast);
|
||||||
let id = loc.id(db);
|
let id = db.as_ref().fns.loc2id(&loc);
|
||||||
Function { id }
|
Function { id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ use crate::{
|
||||||
pub struct HirInterner {
|
pub struct HirInterner {
|
||||||
defs: LocationIntener<DefLoc, DefId>,
|
defs: LocationIntener<DefLoc, DefId>,
|
||||||
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
macros: LocationIntener<MacroCallLoc, MacroCallId>,
|
||||||
fns: LocationIntener<FunctionLoc, FunctionId>,
|
pub(crate) fns: LocationIntener<ItemLoc<ast::FnDef>, FunctionId>,
|
||||||
structs: LocationIntener<StructLoc, StructId>,
|
pub(crate) structs: LocationIntener<ItemLoc<ast::StructDef>, StructId>,
|
||||||
enums: LocationIntener<EnumLoc, EnumId>,
|
pub(crate) enums: LocationIntener<ItemLoc<ast::EnumDef>, EnumId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HirInterner {
|
impl HirInterner {
|
||||||
|
@ -182,56 +182,32 @@ impl<N: AstNode> Clone for ItemLoc<N> {
|
||||||
pub struct FunctionId(RawId);
|
pub struct FunctionId(RawId);
|
||||||
impl_arena_id!(FunctionId);
|
impl_arena_id!(FunctionId);
|
||||||
|
|
||||||
pub(crate) type FunctionLoc = ItemLoc<ast::FnDef>;
|
|
||||||
|
|
||||||
impl FunctionId {
|
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)
|
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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub struct StructId(RawId);
|
pub struct StructId(RawId);
|
||||||
impl_arena_id!(StructId);
|
impl_arena_id!(StructId);
|
||||||
|
|
||||||
pub(crate) type StructLoc = ItemLoc<ast::StructDef>;
|
|
||||||
|
|
||||||
impl StructId {
|
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)
|
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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
pub struct EnumId(RawId);
|
pub struct EnumId(RawId);
|
||||||
impl_arena_id!(EnumId);
|
impl_arena_id!(EnumId);
|
||||||
|
|
||||||
pub(crate) type EnumLoc = ItemLoc<ast::EnumDef>;
|
|
||||||
|
|
||||||
impl EnumId {
|
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)
|
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)
|
/// Def's are a core concept of hir. A `Def` is an Item (function, module, etc)
|
||||||
/// in a specific module.
|
/// in a specific module.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue