aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/lower.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/lower.rs')
-rw-r--r--crates/ra_hir/src/ty/lower.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index a1a2d0f6b..7defa7a9b 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -9,7 +9,7 @@ use std::sync::Arc;
9use std::iter; 9use std::iter;
10 10
11use crate::{ 11use crate::{
12 Function, Struct, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static, 12 Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static,
13 HirDatabase, 13 HirDatabase,
14 type_ref::TypeRef, 14 type_ref::TypeRef,
15 name::KnownName, 15 name::KnownName,
@@ -124,6 +124,7 @@ impl Ty {
124 let def_generic: Option<GenericDef> = match resolved { 124 let def_generic: Option<GenericDef> = match resolved {
125 TypableDef::Function(func) => Some(func.into()), 125 TypableDef::Function(func) => Some(func.into()),
126 TypableDef::Struct(s) => Some(s.into()), 126 TypableDef::Struct(s) => Some(s.into()),
127 TypableDef::Union(u) => Some(u.into()),
127 TypableDef::Enum(e) => Some(e.into()), 128 TypableDef::Enum(e) => Some(e.into()),
128 TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()), 129 TypableDef::EnumVariant(var) => Some(var.parent_enum(db).into()),
129 TypableDef::TypeAlias(t) => Some(t.into()), 130 TypableDef::TypeAlias(t) => Some(t.into()),
@@ -144,6 +145,7 @@ impl Ty {
144 let segment = match resolved { 145 let segment = match resolved {
145 TypableDef::Function(_) 146 TypableDef::Function(_)
146 | TypableDef::Struct(_) 147 | TypableDef::Struct(_)
148 | TypableDef::Union(_)
147 | TypableDef::Enum(_) 149 | TypableDef::Enum(_)
148 | TypableDef::Const(_) 150 | TypableDef::Const(_)
149 | TypableDef::Static(_) 151 | TypableDef::Static(_)
@@ -293,12 +295,14 @@ pub(crate) fn type_for_def(db: &impl HirDatabase, def: TypableDef, ns: Namespace
293 (TypableDef::Struct(s), Namespace::Values) => type_for_struct_constructor(db, s), 295 (TypableDef::Struct(s), Namespace::Values) => type_for_struct_constructor(db, s),
294 (TypableDef::Enum(e), Namespace::Types) => type_for_adt(db, e), 296 (TypableDef::Enum(e), Namespace::Types) => type_for_adt(db, e),
295 (TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v), 297 (TypableDef::EnumVariant(v), Namespace::Values) => type_for_enum_variant_constructor(db, v),
298 (TypableDef::Union(u), Namespace::Types) => type_for_adt(db, u),
296 (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t), 299 (TypableDef::TypeAlias(t), Namespace::Types) => type_for_type_alias(db, t),
297 (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c), 300 (TypableDef::Const(c), Namespace::Values) => type_for_const(db, c),
298 (TypableDef::Static(c), Namespace::Values) => type_for_static(db, c), 301 (TypableDef::Static(c), Namespace::Values) => type_for_static(db, c),
299 302
300 // 'error' cases: 303 // 'error' cases:
301 (TypableDef::Function(_), Namespace::Types) => Ty::Unknown, 304 (TypableDef::Function(_), Namespace::Types) => Ty::Unknown,
305 (TypableDef::Union(_), Namespace::Values) => Ty::Unknown,
302 (TypableDef::Enum(_), Namespace::Values) => Ty::Unknown, 306 (TypableDef::Enum(_), Namespace::Values) => Ty::Unknown,
303 (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown, 307 (TypableDef::EnumVariant(_), Namespace::Types) => Ty::Unknown,
304 (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown, 308 (TypableDef::TypeAlias(_), Namespace::Values) => Ty::Unknown,
@@ -467,19 +471,21 @@ fn type_for_type_alias(db: &impl HirDatabase, t: TypeAlias) -> Ty {
467pub enum TypableDef { 471pub enum TypableDef {
468 Function(Function), 472 Function(Function),
469 Struct(Struct), 473 Struct(Struct),
474 Union(Union),
470 Enum(Enum), 475 Enum(Enum),
471 EnumVariant(EnumVariant), 476 EnumVariant(EnumVariant),
472 TypeAlias(TypeAlias), 477 TypeAlias(TypeAlias),
473 Const(Const), 478 Const(Const),
474 Static(Static), 479 Static(Static),
475} 480}
476impl_froms!(TypableDef: Function, Struct, Enum, EnumVariant, TypeAlias, Const, Static); 481impl_froms!(TypableDef: Function, Struct, Union, Enum, EnumVariant, TypeAlias, Const, Static);
477 482
478impl From<ModuleDef> for Option<TypableDef> { 483impl From<ModuleDef> for Option<TypableDef> {
479 fn from(def: ModuleDef) -> Option<TypableDef> { 484 fn from(def: ModuleDef) -> Option<TypableDef> {
480 let res = match def { 485 let res = match def {
481 ModuleDef::Function(f) => f.into(), 486 ModuleDef::Function(f) => f.into(),
482 ModuleDef::Struct(s) => s.into(), 487 ModuleDef::Struct(s) => s.into(),
488 ModuleDef::Union(u) => u.into(),
483 ModuleDef::Enum(e) => e.into(), 489 ModuleDef::Enum(e) => e.into(),
484 ModuleDef::EnumVariant(v) => v.into(), 490 ModuleDef::EnumVariant(v) => v.into(),
485 ModuleDef::TypeAlias(t) => t.into(), 491 ModuleDef::TypeAlias(t) => t.into(),