mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Merge #3406
3406: Simplify: remove couple of useless functions r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
a484e9c730
@ -7,8 +7,6 @@ use ra_prof::profile;
|
||||
use ra_syntax::{ast, AstNode};
|
||||
use test_utils::tested_by;
|
||||
|
||||
pub use ra_ide_db::defs::{from_module_def, from_struct_field};
|
||||
|
||||
pub enum NameRefClass {
|
||||
NameDefinition(NameDefinition),
|
||||
FieldShorthand { local: Local, field: NameDefinition },
|
||||
@ -68,14 +66,14 @@ pub(crate) fn classify_name_ref(
|
||||
let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?;
|
||||
let resolved = sema.resolve_path(&path)?;
|
||||
let res = match resolved {
|
||||
PathResolution::Def(def) => from_module_def(def),
|
||||
PathResolution::Def(def) => NameDefinition::ModuleDef(def),
|
||||
PathResolution::AssocItem(item) => {
|
||||
let def = match item {
|
||||
hir::AssocItem::Function(it) => it.into(),
|
||||
hir::AssocItem::Const(it) => it.into(),
|
||||
hir::AssocItem::TypeAlias(it) => it.into(),
|
||||
};
|
||||
from_module_def(def)
|
||||
NameDefinition::ModuleDef(def)
|
||||
}
|
||||
PathResolution::Local(local) => NameDefinition::Local(local),
|
||||
PathResolution::TypeParam(par) => NameDefinition::TypeParam(par),
|
||||
|
@ -111,47 +111,47 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
|
||||
},
|
||||
ast::RecordFieldDef(it) => {
|
||||
let field: hir::StructField = sema.to_def(&it)?;
|
||||
Some(from_struct_field(field))
|
||||
Some(NameDefinition::StructField(field))
|
||||
},
|
||||
ast::Module(it) => {
|
||||
let def = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::StructDef(it) => {
|
||||
let def: hir::Struct = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::UnionDef(it) => {
|
||||
let def: hir::Union = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::EnumDef(it) => {
|
||||
let def: hir::Enum = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::TraitDef(it) => {
|
||||
let def: hir::Trait = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::StaticDef(it) => {
|
||||
let def: hir::Static = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::EnumVariant(it) => {
|
||||
let def: hir::EnumVariant = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::FnDef(it) => {
|
||||
let def: hir::Function = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::ConstDef(it) => {
|
||||
let def: hir::Const = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::TypeAliasDef(it) => {
|
||||
let def: hir::TypeAlias = sema.to_def(&it)?;
|
||||
Some(from_module_def(def.into()))
|
||||
Some(NameDefinition::ModuleDef(def.into()))
|
||||
},
|
||||
ast::MacroCall(it) => {
|
||||
let def = sema.to_def(&it)?;
|
||||
@ -165,11 +165,3 @@ fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Opti
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_struct_field(field: StructField) -> NameDefinition {
|
||||
NameDefinition::StructField(field)
|
||||
}
|
||||
|
||||
pub fn from_module_def(def: ModuleDef) -> NameDefinition {
|
||||
NameDefinition::ModuleDef(def)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user