mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
rename AdtDef -> Adt
This commit is contained in:
parent
bcf30d389c
commit
114a1b878e
20 changed files with 90 additions and 99 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use hir::{db::HirDatabase, AdtDef, HasSource};
|
use hir::{db::HirDatabase, Adt, HasSource};
|
||||||
use ra_syntax::ast::{self, AstNode, NameOwner};
|
use ra_syntax::ast::{self, AstNode, NameOwner};
|
||||||
|
|
||||||
use crate::{ast_editor::AstBuilder, Assist, AssistCtx, AssistId};
|
use crate::{ast_editor::AstBuilder, Assist, AssistCtx, AssistId};
|
||||||
|
@ -60,7 +60,7 @@ fn resolve_enum_def(
|
||||||
let expr_ty = analyzer.type_of(db, &expr)?;
|
let expr_ty = analyzer.type_of(db, &expr)?;
|
||||||
|
|
||||||
analyzer.autoderef(db, expr_ty).find_map(|ty| match ty.as_adt() {
|
analyzer.autoderef(db, expr_ty).find_map(|ty| match ty.as_adt() {
|
||||||
Some((AdtDef::Enum(e), _)) => Some(e.source(db).ast),
|
Some((Adt::Enum(e), _)) => Some(e.source(db).ast),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl BuiltinType {
|
||||||
pub enum ModuleDef {
|
pub enum ModuleDef {
|
||||||
Module(Module),
|
Module(Module),
|
||||||
Function(Function),
|
Function(Function),
|
||||||
AdtDef(AdtDef),
|
Adt(Adt),
|
||||||
// Can't be directly declared, but can be imported.
|
// Can't be directly declared, but can be imported.
|
||||||
EnumVariant(EnumVariant),
|
EnumVariant(EnumVariant),
|
||||||
Const(Const),
|
Const(Const),
|
||||||
|
@ -139,7 +139,7 @@ pub enum ModuleDef {
|
||||||
impl_froms!(
|
impl_froms!(
|
||||||
ModuleDef: Module,
|
ModuleDef: Module,
|
||||||
Function,
|
Function,
|
||||||
AdtDef(Struct, Enum, Union),
|
Adt(Struct, Enum, Union),
|
||||||
EnumVariant,
|
EnumVariant,
|
||||||
Const,
|
Const,
|
||||||
Static,
|
Static,
|
||||||
|
@ -496,37 +496,38 @@ impl EnumVariant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A Data Type
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum AdtDef {
|
pub enum Adt {
|
||||||
Struct(Struct),
|
Struct(Struct),
|
||||||
Union(Union),
|
Union(Union),
|
||||||
Enum(Enum),
|
Enum(Enum),
|
||||||
}
|
}
|
||||||
impl_froms!(AdtDef: Struct, Union, Enum);
|
impl_froms!(Adt: Struct, Union, Enum);
|
||||||
|
|
||||||
impl AdtDef {
|
impl Adt {
|
||||||
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
pub fn ty(self, db: &impl HirDatabase) -> Ty {
|
||||||
match self {
|
match self {
|
||||||
AdtDef::Struct(it) => it.ty(db),
|
Adt::Struct(it) => it.ty(db),
|
||||||
AdtDef::Union(it) => it.ty(db),
|
Adt::Union(it) => it.ty(db),
|
||||||
AdtDef::Enum(it) => it.ty(db),
|
Adt::Enum(it) => it.ty(db),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||||
match self {
|
match self {
|
||||||
AdtDef::Struct(s) => s.module(db),
|
Adt::Struct(s) => s.module(db),
|
||||||
AdtDef::Union(s) => s.module(db),
|
Adt::Union(s) => s.module(db),
|
||||||
AdtDef::Enum(e) => e.module(db),
|
Adt::Enum(e) => e.module(db),
|
||||||
}
|
}
|
||||||
.krate(db)
|
.krate(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
pub(crate) fn resolver(self, db: &impl HirDatabase) -> Resolver {
|
||||||
match self {
|
match self {
|
||||||
AdtDef::Struct(it) => it.resolver(db),
|
Adt::Struct(it) => it.resolver(db),
|
||||||
AdtDef::Union(it) => it.resolver(db),
|
Adt::Union(it) => it.resolver(db),
|
||||||
AdtDef::Enum(it) => it.resolver(db),
|
Adt::Enum(it) => it.resolver(db),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
name,
|
name,
|
||||||
path::{PathKind, PathSegment},
|
path::{PathKind, PathSegment},
|
||||||
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
|
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
|
||||||
AdtDef, Function, Name, Path,
|
Adt, Function, Name, Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Expr, ExprId, RecordLitField};
|
use super::{Expr, ExprId, RecordLitField};
|
||||||
|
@ -58,7 +58,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let struct_def = match self.infer[id].as_adt() {
|
let struct_def = match self.infer[id].as_adt() {
|
||||||
Some((AdtDef::Struct(s), _)) => s,
|
Some((Adt::Struct(s), _)) => s,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let std_result_ctor = TypeCtor::Adt(AdtDef::Enum(std_result_enum));
|
let std_result_ctor = TypeCtor::Adt(Adt::Enum(std_result_enum));
|
||||||
let params = match &mismatch.expected {
|
let params = match &mismatch.expected {
|
||||||
Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &std_result_ctor => parameters,
|
Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &std_result_ctor => parameters,
|
||||||
_ => return,
|
_ => return,
|
||||||
|
|
|
@ -12,8 +12,8 @@ use crate::{
|
||||||
name::SELF_TYPE,
|
name::SELF_TYPE,
|
||||||
path::Path,
|
path::Path,
|
||||||
type_ref::{TypeBound, TypeRef},
|
type_ref::{TypeBound, TypeRef},
|
||||||
AdtDef, AsName, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct,
|
Adt, AsName, Container, Enum, EnumVariant, Function, HasSource, ImplBlock, Name, Struct, Trait,
|
||||||
Trait, TypeAlias, Union,
|
TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Data about a generic parameter (to a function, struct, impl, ...).
|
/// Data about a generic parameter (to a function, struct, impl, ...).
|
||||||
|
@ -47,7 +47,7 @@ pub struct WherePredicate {
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
|
||||||
pub enum GenericDef {
|
pub enum GenericDef {
|
||||||
Function(Function),
|
Function(Function),
|
||||||
AdtDef(AdtDef),
|
Adt(Adt),
|
||||||
Trait(Trait),
|
Trait(Trait),
|
||||||
TypeAlias(TypeAlias),
|
TypeAlias(TypeAlias),
|
||||||
ImplBlock(ImplBlock),
|
ImplBlock(ImplBlock),
|
||||||
|
@ -57,7 +57,7 @@ pub enum GenericDef {
|
||||||
}
|
}
|
||||||
impl_froms!(
|
impl_froms!(
|
||||||
GenericDef: Function,
|
GenericDef: Function,
|
||||||
AdtDef(Struct, Enum, Union),
|
Adt(Struct, Enum, Union),
|
||||||
Trait,
|
Trait,
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
ImplBlock,
|
ImplBlock,
|
||||||
|
@ -74,7 +74,7 @@ impl GenericParams {
|
||||||
GenericDef::Function(it) => it.container(db).map(GenericDef::from),
|
GenericDef::Function(it) => it.container(db).map(GenericDef::from),
|
||||||
GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from),
|
GenericDef::TypeAlias(it) => it.container(db).map(GenericDef::from),
|
||||||
GenericDef::EnumVariant(it) => Some(it.parent_enum(db).into()),
|
GenericDef::EnumVariant(it) => Some(it.parent_enum(db).into()),
|
||||||
GenericDef::AdtDef(_) | GenericDef::Trait(_) => None,
|
GenericDef::Adt(_) | GenericDef::Trait(_) => None,
|
||||||
GenericDef::ImplBlock(_) => None,
|
GenericDef::ImplBlock(_) => None,
|
||||||
};
|
};
|
||||||
generics.parent_params = parent.map(|p| db.generic_params(p));
|
generics.parent_params = parent.map(|p| db.generic_params(p));
|
||||||
|
@ -82,9 +82,9 @@ impl GenericParams {
|
||||||
// FIXME: add `: Sized` bound for everything except for `Self` in traits
|
// FIXME: add `: Sized` bound for everything except for `Self` in traits
|
||||||
match def {
|
match def {
|
||||||
GenericDef::Function(it) => generics.fill(&it.source(db).ast, start),
|
GenericDef::Function(it) => generics.fill(&it.source(db).ast, start),
|
||||||
GenericDef::AdtDef(AdtDef::Struct(it)) => generics.fill(&it.source(db).ast, start),
|
GenericDef::Adt(Adt::Struct(it)) => generics.fill(&it.source(db).ast, start),
|
||||||
GenericDef::AdtDef(AdtDef::Union(it)) => generics.fill(&it.source(db).ast, start),
|
GenericDef::Adt(Adt::Union(it)) => generics.fill(&it.source(db).ast, start),
|
||||||
GenericDef::AdtDef(AdtDef::Enum(it)) => generics.fill(&it.source(db).ast, start),
|
GenericDef::Adt(Adt::Enum(it)) => generics.fill(&it.source(db).ast, start),
|
||||||
GenericDef::Trait(it) => {
|
GenericDef::Trait(it) => {
|
||||||
// traits get the Self type as an implicit first type parameter
|
// traits get the Self type as an implicit first type parameter
|
||||||
generics.params.push(GenericParam { idx: start, name: SELF_TYPE, default: None });
|
generics.params.push(GenericParam { idx: start, name: SELF_TYPE, default: None });
|
||||||
|
@ -188,7 +188,7 @@ impl GenericDef {
|
||||||
pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver {
|
pub(crate) fn resolver(&self, db: &impl HirDatabase) -> crate::Resolver {
|
||||||
match self {
|
match self {
|
||||||
GenericDef::Function(inner) => inner.resolver(db),
|
GenericDef::Function(inner) => inner.resolver(db),
|
||||||
GenericDef::AdtDef(adt) => adt.resolver(db),
|
GenericDef::Adt(adt) => adt.resolver(db),
|
||||||
GenericDef::Trait(inner) => inner.resolver(db),
|
GenericDef::Trait(inner) => inner.resolver(db),
|
||||||
GenericDef::TypeAlias(inner) => inner.resolver(db),
|
GenericDef::TypeAlias(inner) => inner.resolver(db),
|
||||||
GenericDef::ImplBlock(inner) => inner.resolver(db),
|
GenericDef::ImplBlock(inner) => inner.resolver(db),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use ra_syntax::{ast::AttrsOwner, SmolStr};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||||
AdtDef, Crate, Enum, Function, HasSource, ImplBlock, Module, ModuleDef, Static, Struct, Trait,
|
Adt, Crate, Enum, Function, HasSource, ImplBlock, Module, ModuleDef, Static, Struct, Trait,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
@ -107,10 +107,8 @@ impl LangItems {
|
||||||
ModuleDef::Trait(trait_) => {
|
ModuleDef::Trait(trait_) => {
|
||||||
self.collect_lang_item(db, trait_, LangItemTarget::Trait)
|
self.collect_lang_item(db, trait_, LangItemTarget::Trait)
|
||||||
}
|
}
|
||||||
ModuleDef::AdtDef(AdtDef::Enum(e)) => {
|
ModuleDef::Adt(Adt::Enum(e)) => self.collect_lang_item(db, e, LangItemTarget::Enum),
|
||||||
self.collect_lang_item(db, e, LangItemTarget::Enum)
|
ModuleDef::Adt(Adt::Struct(s)) => {
|
||||||
}
|
|
||||||
ModuleDef::AdtDef(AdtDef::Struct(s)) => {
|
|
||||||
self.collect_lang_item(db, s, LangItemTarget::Struct)
|
self.collect_lang_item(db, s, LangItemTarget::Struct)
|
||||||
}
|
}
|
||||||
ModuleDef::Function(f) => self.collect_lang_item(db, f, LangItemTarget::Function),
|
ModuleDef::Function(f) => self.collect_lang_item(db, f, LangItemTarget::Function),
|
||||||
|
|
|
@ -85,7 +85,7 @@ pub use self::{
|
||||||
pub use self::code_model::{
|
pub use self::code_model::{
|
||||||
docs::{DocDef, Docs, Documentation},
|
docs::{DocDef, Docs, Documentation},
|
||||||
src::{HasBodySource, HasSource, Source},
|
src::{HasBodySource, HasSource, Source},
|
||||||
AdtDef, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
|
Adt, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
|
||||||
EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, ModuleDef, ModuleSource,
|
EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, ModuleDef, ModuleSource,
|
||||||
Static, Struct, StructField, Trait, TypeAlias, Union,
|
Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,8 +69,8 @@ use crate::{
|
||||||
diagnostics::DiagnosticSink,
|
diagnostics::DiagnosticSink,
|
||||||
ids::MacroDefId,
|
ids::MacroDefId,
|
||||||
nameres::diagnostics::DefDiagnostic,
|
nameres::diagnostics::DefDiagnostic,
|
||||||
AdtDef, AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path,
|
Adt, AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind,
|
||||||
PathKind, Trait,
|
Trait,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) use self::raw::{ImportSourceMap, RawItems};
|
pub(crate) use self::raw::{ImportSourceMap, RawItems};
|
||||||
|
@ -426,7 +426,7 @@ impl CrateDefMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModuleDef::AdtDef(AdtDef::Enum(e)) => {
|
ModuleDef::Adt(Adt::Enum(e)) => {
|
||||||
// enum variant
|
// enum variant
|
||||||
tested_by!(can_import_enum_variant);
|
tested_by!(can_import_enum_variant);
|
||||||
match e.variant(db, &segment.name) {
|
match e.variant(db, &segment.name) {
|
||||||
|
|
|
@ -13,8 +13,8 @@ use crate::{
|
||||||
raw, Crate, CrateDefMap, CrateModuleId, ModuleData, ModuleDef, PerNs, ReachedFixedPoint,
|
raw, Crate, CrateDefMap, CrateModuleId, ModuleData, ModuleDef, PerNs, ReachedFixedPoint,
|
||||||
Resolution, ResolveMode,
|
Resolution, ResolveMode,
|
||||||
},
|
},
|
||||||
AdtDef, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, PathKind,
|
Adt, AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, PathKind, Static,
|
||||||
Static, Struct, Trait, TypeAlias, Union,
|
Struct, Trait, TypeAlias, Union,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
|
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
|
||||||
|
@ -314,7 +314,7 @@ where
|
||||||
.push((module_id, import_id));
|
.push((module_id, import_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(ModuleDef::AdtDef(AdtDef::Enum(e))) => {
|
Some(ModuleDef::Adt(Adt::Enum(e))) => {
|
||||||
tested_by!(glob_enum);
|
tested_by!(glob_enum);
|
||||||
// glob import from enum => just import all the variants
|
// glob import from enum => just import all the variants
|
||||||
let variants = e.variants(self.db);
|
let variants = e.variants(self.db);
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
name::{Name, SELF_PARAM, SELF_TYPE},
|
name::{Name, SELF_PARAM, SELF_TYPE},
|
||||||
nameres::{CrateDefMap, CrateModuleId, PerNs},
|
nameres::{CrateDefMap, CrateModuleId, PerNs},
|
||||||
path::Path,
|
path::Path,
|
||||||
AdtDef, Enum, MacroDef, ModuleDef, Struct, Trait,
|
Adt, Enum, MacroDef, ModuleDef, Struct, Trait,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
|
@ -143,7 +143,7 @@ impl Resolver {
|
||||||
) -> Option<Struct> {
|
) -> Option<Struct> {
|
||||||
let res = self.resolve_path_segments(db, path).into_fully_resolved().take_types()?;
|
let res = self.resolve_path_segments(db, path).into_fully_resolved().take_types()?;
|
||||||
match res {
|
match res {
|
||||||
Resolution::Def(ModuleDef::AdtDef(AdtDef::Struct(it))) => Some(it),
|
Resolution::Def(ModuleDef::Adt(Adt::Struct(it))) => Some(it),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ impl Resolver {
|
||||||
pub(crate) fn resolve_known_enum(&self, db: &impl HirDatabase, path: &Path) -> Option<Enum> {
|
pub(crate) fn resolve_known_enum(&self, db: &impl HirDatabase, path: &Path) -> Option<Enum> {
|
||||||
let res = self.resolve_path_segments(db, path).into_fully_resolved().take_types()?;
|
let res = self.resolve_path_segments(db, path).into_fully_resolved().take_types()?;
|
||||||
match res {
|
match res {
|
||||||
Resolution::Def(ModuleDef::AdtDef(AdtDef::Enum(it))) => Some(it),
|
Resolution::Def(ModuleDef::Adt(Adt::Enum(it))) => Some(it),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
|
||||||
use crate::{db::HirDatabase, type_ref::Mutability, AdtDef, GenericParams, Name, Trait, TypeAlias};
|
use crate::{db::HirDatabase, type_ref::Mutability, Adt, GenericParams, Name, Trait, TypeAlias};
|
||||||
use display::{HirDisplay, HirFormatter};
|
use display::{HirDisplay, HirFormatter};
|
||||||
|
|
||||||
pub(crate) use autoderef::autoderef;
|
pub(crate) use autoderef::autoderef;
|
||||||
|
@ -47,7 +47,7 @@ pub enum TypeCtor {
|
||||||
Float(primitive::UncertainFloatTy),
|
Float(primitive::UncertainFloatTy),
|
||||||
|
|
||||||
/// Structures, enumerations and unions.
|
/// Structures, enumerations and unions.
|
||||||
Adt(AdtDef),
|
Adt(Adt),
|
||||||
|
|
||||||
/// The pointee of a string slice. Written as `str`.
|
/// The pointee of a string slice. Written as `str`.
|
||||||
Str,
|
Str,
|
||||||
|
@ -458,7 +458,7 @@ impl Ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_adt(&self) -> Option<(AdtDef, &Substs)> {
|
pub fn as_adt(&self) -> Option<(Adt, &Substs)> {
|
||||||
match self {
|
match self {
|
||||||
Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => {
|
Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_def), parameters }) => {
|
||||||
Some((*adt_def, parameters))
|
Some((*adt_def, parameters))
|
||||||
|
@ -726,9 +726,9 @@ impl HirDisplay for ApplicationTy {
|
||||||
}
|
}
|
||||||
TypeCtor::Adt(def_id) => {
|
TypeCtor::Adt(def_id) => {
|
||||||
let name = match def_id {
|
let name = match def_id {
|
||||||
AdtDef::Struct(s) => s.name(f.db),
|
Adt::Struct(s) => s.name(f.db),
|
||||||
AdtDef::Union(u) => u.name(f.db),
|
Adt::Union(u) => u.name(f.db),
|
||||||
AdtDef::Enum(e) => e.name(f.db),
|
Adt::Enum(e) => e.name(f.db),
|
||||||
}
|
}
|
||||||
.unwrap_or_else(Name::missing);
|
.unwrap_or_else(Name::missing);
|
||||||
write!(f, "{}", name)?;
|
write!(f, "{}", name)?;
|
||||||
|
|
|
@ -48,7 +48,7 @@ use crate::{
|
||||||
resolve::{Resolution, Resolver},
|
resolve::{Resolution, Resolver},
|
||||||
ty::infer::diagnostics::InferenceDiagnostic,
|
ty::infer::diagnostics::InferenceDiagnostic,
|
||||||
type_ref::{Mutability, TypeRef},
|
type_ref::{Mutability, TypeRef},
|
||||||
AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path,
|
Adt, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path,
|
||||||
StructField,
|
StructField,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
// FIXME remove the duplication between here and `Ty::from_path`?
|
// FIXME remove the duplication between here and `Ty::from_path`?
|
||||||
let substs = Ty::substs_from_path(self.db, resolver, path, def);
|
let substs = Ty::substs_from_path(self.db, resolver, path, def);
|
||||||
match def {
|
match def {
|
||||||
TypableDef::AdtDef(AdtDef::Struct(s)) => {
|
TypableDef::Adt(Adt::Struct(s)) => {
|
||||||
let ty = s.ty(self.db);
|
let ty = s.ty(self.db);
|
||||||
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
||||||
(ty, Some(s.into()))
|
(ty, Some(s.into()))
|
||||||
|
@ -678,8 +678,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
let ty = self.insert_type_vars(ty.apply_substs(substs));
|
||||||
(ty, Some(var.into()))
|
(ty, Some(var.into()))
|
||||||
}
|
}
|
||||||
TypableDef::AdtDef(AdtDef::Enum(_))
|
TypableDef::Adt(Adt::Enum(_))
|
||||||
| TypableDef::AdtDef(AdtDef::Union(_))
|
| TypableDef::Adt(Adt::Union(_))
|
||||||
| TypableDef::TypeAlias(_)
|
| TypableDef::TypeAlias(_)
|
||||||
| TypableDef::Function(_)
|
| TypableDef::Function(_)
|
||||||
| TypableDef::Const(_)
|
| TypableDef::Const(_)
|
||||||
|
@ -1185,7 +1185,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
let i = name.to_string().parse::<usize>().ok();
|
let i = name.to_string().parse::<usize>().ok();
|
||||||
i.and_then(|i| a_ty.parameters.0.get(i).cloned())
|
i.and_then(|i| a_ty.parameters.0.get(i).cloned())
|
||||||
}
|
}
|
||||||
TypeCtor::Adt(AdtDef::Struct(s)) => s.field(self.db, name).map(|field| {
|
TypeCtor::Adt(Adt::Struct(s)) => s.field(self.db, name).map(|field| {
|
||||||
self.write_field_resolution(tgt_expr, field);
|
self.write_field_resolution(tgt_expr, field);
|
||||||
field.ty(self.db).subst(&a_ty.parameters)
|
field.ty(self.db).subst(&a_ty.parameters)
|
||||||
}),
|
}),
|
||||||
|
@ -1489,7 +1489,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
trait_.associated_type_by_name(self.db, &name::OUTPUT)
|
trait_.associated_type_by_name(self.db, &name::OUTPUT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_boxed_box(&self) -> Option<AdtDef> {
|
fn resolve_boxed_box(&self) -> Option<Adt> {
|
||||||
let boxed_box_path = Path {
|
let boxed_box_path = Path {
|
||||||
kind: PathKind::Abs,
|
kind: PathKind::Abs,
|
||||||
segments: vec![
|
segments: vec![
|
||||||
|
@ -1499,7 +1499,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
let struct_ = self.resolver.resolve_known_struct(self.db, &boxed_box_path)?;
|
let struct_ = self.resolver.resolve_known_struct(self.db, &boxed_box_path)?;
|
||||||
Some(AdtDef::Struct(struct_))
|
Some(Adt::Struct(struct_))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::{
|
||||||
nameres::Namespace,
|
nameres::Namespace,
|
||||||
path::{GenericArg, PathSegment},
|
path::{GenericArg, PathSegment},
|
||||||
resolve::{Resolution, Resolver},
|
resolve::{Resolution, Resolver},
|
||||||
ty::AdtDef,
|
ty::Adt,
|
||||||
type_ref::{TypeBound, TypeRef},
|
type_ref::{TypeBound, TypeRef},
|
||||||
BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField,
|
BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField,
|
||||||
Trait, TypeAlias, Union,
|
Trait, TypeAlias, Union,
|
||||||
|
@ -172,7 +172,7 @@ impl Ty {
|
||||||
) -> Substs {
|
) -> Substs {
|
||||||
let def_generic: Option<GenericDef> = match resolved {
|
let def_generic: Option<GenericDef> = match resolved {
|
||||||
TypableDef::Function(func) => Some(func.into()),
|
TypableDef::Function(func) => Some(func.into()),
|
||||||
TypableDef::AdtDef(adt) => Some(adt.into()),
|
TypableDef::Adt(adt) => Some(adt.into()),
|
||||||
TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()),
|
TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()),
|
||||||
TypableDef::TypeAlias(t) => Some(t.into()),
|
TypableDef::TypeAlias(t) => Some(t.into()),
|
||||||
TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None,
|
TypableDef::Const(_) | TypableDef::Static(_) | TypableDef::BuiltinType(_) => None,
|
||||||
|
@ -191,7 +191,7 @@ impl Ty {
|
||||||
let last = path.segments.last().expect("path should have at least one segment");
|
let last = path.segments.last().expect("path should have at least one segment");
|
||||||
let segment = match resolved {
|
let segment = match resolved {
|
||||||
TypableDef::Function(_)
|
TypableDef::Function(_)
|
||||||
| TypableDef::AdtDef(_)
|
| TypableDef::Adt(_)
|
||||||
| TypableDef::Const(_)
|
| TypableDef::Const(_)
|
||||||
| TypableDef::Static(_)
|
| TypableDef::Static(_)
|
||||||
| TypableDef::TypeAlias(_)
|
| TypableDef::TypeAlias(_)
|
||||||
|
@ -406,10 +406,8 @@ fn assoc_type_bindings_from_type_bound<'a>(
|
||||||
pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty {
|
pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace) -> Ty {
|
||||||
match (def, ns) {
|
match (def, ns) {
|
||||||
(TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f),
|
(TypableDef::Function(f), Namespace::Values) => type_for_fn(db, f),
|
||||||
(TypableDef::AdtDef(AdtDef::Struct(s)), Namespace::Values) => {
|
(TypableDef::Adt(Adt::Struct(s)), Namespace::Values) => type_for_struct_constructor(db, s),
|
||||||
type_for_struct_constructor(db, s)
|
(TypableDef::Adt(adt), Namespace::Types) => type_for_adt(db, adt),
|
||||||
}
|
|
||||||
(TypableDef::AdtDef(adt), Namespace::Types) => type_for_adt(db, adt),
|
|
||||||
(TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v),
|
(TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v),
|
||||||
(TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t),
|
(TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t),
|
||||||
(TypableDef::Const(c), Namespace::Values) => type_for_const(db, c),
|
(TypableDef::Const(c), Namespace::Values) => type_for_const(db, c),
|
||||||
|
@ -418,8 +416,8 @@ pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace
|
||||||
|
|
||||||
// 'error' cases:
|
// 'error' cases:
|
||||||
(TypableDef::Function(_), Namespace::Types) => Ty::Unknown,
|
(TypableDef::Function(_), Namespace::Types) => Ty::Unknown,
|
||||||
(TypableDef::AdtDef(AdtDef::Union(_)), Namespace::Values) => Ty::Unknown,
|
(TypableDef::Adt(Adt::Union(_)), Namespace::Values) => Ty::Unknown,
|
||||||
(TypableDef::AdtDef(AdtDef::Enum(_)), Namespace::Values) => Ty::Unknown,
|
(TypableDef::Adt(Adt::Enum(_)), Namespace::Values) => Ty::Unknown,
|
||||||
(TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown,
|
(TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown,
|
||||||
(TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown,
|
(TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown,
|
||||||
(TypableDef::Const(_), Namespace::Types) => Ty::Unknown,
|
(TypableDef::Const(_), Namespace::Types) => Ty::Unknown,
|
||||||
|
@ -587,7 +585,7 @@ fn type_for_enum_variant_constructor(db: &impl HirDatabase, def: EnumVariant) ->
|
||||||
Ty::apply(TypeCtor::FnDef(def.into()), substs)
|
Ty::apply(TypeCtor::FnDef(def.into()), substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_for_adt(db: &impl HirDatabase, adt: impl Into<AdtDef> + HasGenericParams) -> Ty {
|
fn type_for_adt(db: &impl HirDatabase, adt: impl Into<Adt> + HasGenericParams) -> Ty {
|
||||||
let generics = adt.generic_params(db);
|
let generics = adt.generic_params(db);
|
||||||
Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics))
|
Ty::apply(TypeCtor::Adt(adt.into()), Substs::identity(&generics))
|
||||||
}
|
}
|
||||||
|
@ -604,7 +602,7 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum TypableDef {
|
pub enum TypableDef {
|
||||||
Function(Function),
|
Function(Function),
|
||||||
AdtDef(AdtDef),
|
Adt(Adt),
|
||||||
EnumVariant(EnumVariant),
|
EnumVariant(EnumVariant),
|
||||||
TypeAlias(TypeAlias),
|
TypeAlias(TypeAlias),
|
||||||
Const(Const),
|
Const(Const),
|
||||||
|
@ -613,7 +611,7 @@ pub enum TypableDef {
|
||||||
}
|
}
|
||||||
impl_froms!(
|
impl_froms!(
|
||||||
TypableDef: Function,
|
TypableDef: Function,
|
||||||
AdtDef(Struct, Enum, Union),
|
Adt(Struct, Enum, Union),
|
||||||
EnumVariant,
|
EnumVariant,
|
||||||
TypeAlias,
|
TypeAlias,
|
||||||
Const,
|
Const,
|
||||||
|
@ -625,7 +623,7 @@ impl From<ModuleDef> for Option<TypableDef> {
|
||||||
fn from(def: ModuleDef) -> Option<TypableDef> {
|
fn from(def: ModuleDef) -> Option<TypableDef> {
|
||||||
let res = match def {
|
let res = match def {
|
||||||
ModuleDef::Function(f) => f.into(),
|
ModuleDef::Function(f) => f.into(),
|
||||||
ModuleDef::AdtDef(adt) => adt.into(),
|
ModuleDef::Adt(adt) => adt.into(),
|
||||||
ModuleDef::EnumVariant(v) => v.into(),
|
ModuleDef::EnumVariant(v) => v.into(),
|
||||||
ModuleDef::TypeAlias(t) => t.into(),
|
ModuleDef::TypeAlias(t) => t.into(),
|
||||||
ModuleDef::Const(v) => v.into(),
|
ModuleDef::Const(v) => v.into(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use hir::{AdtDef, Ty, TypeCtor};
|
use hir::{Adt, Ty, TypeCtor};
|
||||||
|
|
||||||
use crate::completion::completion_item::CompletionKind;
|
use crate::completion::completion_item::CompletionKind;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -37,7 +37,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
|
||||||
for receiver in ctx.analyzer.autoderef(ctx.db, receiver) {
|
for receiver in ctx.analyzer.autoderef(ctx.db, receiver) {
|
||||||
if let Ty::Apply(a_ty) = receiver {
|
if let Ty::Apply(a_ty) = receiver {
|
||||||
match a_ty.ctor {
|
match a_ty.ctor {
|
||||||
TypeCtor::Adt(AdtDef::Struct(s)) => {
|
TypeCtor::Adt(Adt::Struct(s)) => {
|
||||||
for field in s.fields(ctx.db) {
|
for field in s.fields(ctx.db) {
|
||||||
acc.add_field(ctx, field, &a_ty.parameters);
|
acc.add_field(ctx, field, &a_ty.parameters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use hir::{AdtDef, Either, Resolution};
|
use hir::{Adt, Either, Resolution};
|
||||||
use ra_syntax::AstNode;
|
use ra_syntax::AstNode;
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
|
@ -37,14 +37,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
||||||
acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
|
acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ModuleDef::AdtDef(_) | hir::ModuleDef::TypeAlias(_) => {
|
hir::ModuleDef::Adt(_) | hir::ModuleDef::TypeAlias(_) => {
|
||||||
if let hir::ModuleDef::AdtDef(AdtDef::Enum(e)) = def {
|
if let hir::ModuleDef::Adt(Adt::Enum(e)) = def {
|
||||||
for variant in e.variants(ctx.db) {
|
for variant in e.variants(ctx.db) {
|
||||||
acc.add_enum_variant(ctx, variant);
|
acc.add_enum_variant(ctx, variant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ty = match def {
|
let ty = match def {
|
||||||
hir::ModuleDef::AdtDef(adt) => adt.ty(ctx.db),
|
hir::ModuleDef::Adt(adt) => adt.ty(ctx.db),
|
||||||
hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
|
hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
match def {
|
match def {
|
||||||
hir::ModuleDef::AdtDef(hir::AdtDef::Enum(..))
|
hir::ModuleDef::Adt(hir::Adt::Enum(..))
|
||||||
| hir::ModuleDef::EnumVariant(..)
|
| hir::ModuleDef::EnumVariant(..)
|
||||||
| hir::ModuleDef::Const(..)
|
| hir::ModuleDef::Const(..)
|
||||||
| hir::ModuleDef::Module(..) => (),
|
| hir::ModuleDef::Module(..) => (),
|
||||||
|
|
|
@ -67,15 +67,13 @@ impl Completions {
|
||||||
Resolution::Def(Function(func)) => {
|
Resolution::Def(Function(func)) => {
|
||||||
return self.add_function_with_name(ctx, Some(local_name), *func);
|
return self.add_function_with_name(ctx, Some(local_name), *func);
|
||||||
}
|
}
|
||||||
Resolution::Def(AdtDef(hir::AdtDef::Struct(it))) => {
|
Resolution::Def(Adt(hir::Adt::Struct(it))) => {
|
||||||
(CompletionItemKind::Struct, it.docs(ctx.db))
|
(CompletionItemKind::Struct, it.docs(ctx.db))
|
||||||
}
|
}
|
||||||
Resolution::Def(AdtDef(hir::AdtDef::Union(it))) => {
|
Resolution::Def(Adt(hir::Adt::Union(it))) => {
|
||||||
(CompletionItemKind::Struct, it.docs(ctx.db))
|
(CompletionItemKind::Struct, it.docs(ctx.db))
|
||||||
}
|
}
|
||||||
Resolution::Def(AdtDef(hir::AdtDef::Enum(it))) => {
|
Resolution::Def(Adt(hir::Adt::Enum(it))) => (CompletionItemKind::Enum, it.docs(ctx.db)),
|
||||||
(CompletionItemKind::Enum, it.docs(ctx.db))
|
|
||||||
}
|
|
||||||
Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
|
Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
|
||||||
Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)),
|
Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)),
|
||||||
Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)),
|
Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)),
|
||||||
|
|
|
@ -178,11 +178,11 @@ impl NavigationTarget {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::AdtDef) -> NavigationTarget {
|
pub(crate) fn from_adt_def(db: &RootDatabase, adt_def: hir::Adt) -> NavigationTarget {
|
||||||
match adt_def {
|
match adt_def {
|
||||||
hir::AdtDef::Struct(it) => NavigationTarget::from_def_source(db, it),
|
hir::Adt::Struct(it) => NavigationTarget::from_def_source(db, it),
|
||||||
hir::AdtDef::Union(it) => NavigationTarget::from_def_source(db, it),
|
hir::Adt::Union(it) => NavigationTarget::from_def_source(db, it),
|
||||||
hir::AdtDef::Enum(it) => NavigationTarget::from_def_source(db, it),
|
hir::Adt::Enum(it) => NavigationTarget::from_def_source(db, it),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ impl NavigationTarget {
|
||||||
let nav = match module_def {
|
let nav = match module_def {
|
||||||
hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module),
|
hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module),
|
||||||
hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func),
|
hir::ModuleDef::Function(func) => NavigationTarget::from_def_source(db, func),
|
||||||
hir::ModuleDef::AdtDef(it) => NavigationTarget::from_adt_def(db, it),
|
hir::ModuleDef::Adt(it) => NavigationTarget::from_adt_def(db, it),
|
||||||
hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it),
|
hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it),
|
||||||
hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it),
|
hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it),
|
||||||
hir::ModuleDef::EnumVariant(it) => NavigationTarget::from_def_source(db, it),
|
hir::ModuleDef::EnumVariant(it) => NavigationTarget::from_def_source(db, it),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use hir::{AdtDef, HasSource, HirDisplay};
|
use hir::{Adt, HasSource, HirDisplay};
|
||||||
use ra_db::SourceDatabase;
|
use ra_db::SourceDatabase;
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
algo::{
|
algo::{
|
||||||
|
@ -129,13 +129,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ModuleDef::Function(it) => res.extend(from_def_source(db, it)),
|
hir::ModuleDef::Function(it) => res.extend(from_def_source(db, it)),
|
||||||
hir::ModuleDef::AdtDef(AdtDef::Struct(it)) => {
|
hir::ModuleDef::Adt(Adt::Struct(it)) => res.extend(from_def_source(db, it)),
|
||||||
res.extend(from_def_source(db, it))
|
hir::ModuleDef::Adt(Adt::Union(it)) => res.extend(from_def_source(db, it)),
|
||||||
}
|
hir::ModuleDef::Adt(Adt::Enum(it)) => res.extend(from_def_source(db, it)),
|
||||||
hir::ModuleDef::AdtDef(AdtDef::Union(it)) => {
|
|
||||||
res.extend(from_def_source(db, it))
|
|
||||||
}
|
|
||||||
hir::ModuleDef::AdtDef(AdtDef::Enum(it)) => res.extend(from_def_source(db, it)),
|
|
||||||
hir::ModuleDef::EnumVariant(it) => res.extend(from_def_source(db, it)),
|
hir::ModuleDef::EnumVariant(it) => res.extend(from_def_source(db, it)),
|
||||||
hir::ModuleDef::Const(it) => res.extend(from_def_source(db, it)),
|
hir::ModuleDef::Const(it) => res.extend(from_def_source(db, it)),
|
||||||
hir::ModuleDef::Static(it) => res.extend(from_def_source(db, it)),
|
hir::ModuleDef::Static(it) => res.extend(from_def_source(db, it)),
|
||||||
|
@ -149,9 +145,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
||||||
Some(SelfType(ty)) => {
|
Some(SelfType(ty)) => {
|
||||||
if let Some((adt_def, _)) = ty.as_adt() {
|
if let Some((adt_def, _)) = ty.as_adt() {
|
||||||
res.extend(match adt_def {
|
res.extend(match adt_def {
|
||||||
hir::AdtDef::Struct(it) => from_def_source(db, it),
|
hir::Adt::Struct(it) => from_def_source(db, it),
|
||||||
hir::AdtDef::Union(it) => from_def_source(db, it),
|
hir::Adt::Union(it) => from_def_source(db, it),
|
||||||
hir::AdtDef::Enum(it) => from_def_source(db, it),
|
hir::Adt::Enum(it) => from_def_source(db, it),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub(crate) fn classify_name_ref(
|
||||||
let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast);
|
let record_lit = field_expr.syntax().ancestors().find_map(ast::RecordLit::cast);
|
||||||
|
|
||||||
if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) {
|
if let Some(ty) = record_lit.and_then(|lit| analyzer.type_of(db, &lit.into())) {
|
||||||
if let Some((hir::AdtDef::Struct(s), _)) = ty.as_adt() {
|
if let Some((hir::Adt::Struct(s), _)) = ty.as_adt() {
|
||||||
let hir_path = hir::Path::from_name_ref(name_ref);
|
let hir_path = hir::Path::from_name_ref(name_ref);
|
||||||
let hir_name = hir_path.as_ident().unwrap();
|
let hir_name = hir_path.as_ident().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
|
||||||
Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type",
|
Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type",
|
||||||
Some(Def(hir::ModuleDef::Module(_))) => "module",
|
Some(Def(hir::ModuleDef::Module(_))) => "module",
|
||||||
Some(Def(hir::ModuleDef::Function(_))) => "function",
|
Some(Def(hir::ModuleDef::Function(_))) => "function",
|
||||||
Some(Def(hir::ModuleDef::AdtDef(_))) => "type",
|
Some(Def(hir::ModuleDef::Adt(_))) => "type",
|
||||||
Some(Def(hir::ModuleDef::EnumVariant(_))) => "constant",
|
Some(Def(hir::ModuleDef::EnumVariant(_))) => "constant",
|
||||||
Some(Def(hir::ModuleDef::Const(_))) => "constant",
|
Some(Def(hir::ModuleDef::Const(_))) => "constant",
|
||||||
Some(Def(hir::ModuleDef::Static(_))) => "constant",
|
Some(Def(hir::ModuleDef::Static(_))) => "constant",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue