diff options
Diffstat (limited to 'crates/ra_hir/src/ty/lower.rs')
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index 0f49a0e54..e29ab8492 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -9,6 +9,7 @@ use std::iter; | |||
9 | use std::sync::Arc; | 9 | use std::sync::Arc; |
10 | 10 | ||
11 | use hir_def::{ | 11 | use hir_def::{ |
12 | builtin_type::BuiltinType, | ||
12 | path::{GenericArg, PathSegment}, | 13 | path::{GenericArg, PathSegment}, |
13 | type_ref::{TypeBound, TypeRef}, | 14 | type_ref::{TypeBound, TypeRef}, |
14 | }; | 15 | }; |
@@ -22,11 +23,13 @@ use crate::{ | |||
22 | db::HirDatabase, | 23 | db::HirDatabase, |
23 | generics::HasGenericParams, | 24 | generics::HasGenericParams, |
24 | generics::{GenericDef, WherePredicate}, | 25 | generics::{GenericDef, WherePredicate}, |
25 | nameres::Namespace, | ||
26 | resolve::{Resolver, TypeNs}, | 26 | resolve::{Resolver, TypeNs}, |
27 | ty::Adt, | 27 | ty::{ |
28 | primitive::{FloatTy, IntTy}, | ||
29 | Adt, | ||
30 | }, | ||
28 | util::make_mut_slice, | 31 | util::make_mut_slice, |
29 | BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField, | 32 | Const, Enum, EnumVariant, Function, ModuleDef, Namespace, Path, Static, Struct, StructField, |
30 | Trait, TypeAlias, Union, | 33 | Trait, TypeAlias, Union, |
31 | }; | 34 | }; |
32 | 35 | ||
@@ -643,14 +646,16 @@ fn type_for_builtin(def: BuiltinType) -> Ty { | |||
643 | BuiltinType::Char => TypeCtor::Char, | 646 | BuiltinType::Char => TypeCtor::Char, |
644 | BuiltinType::Bool => TypeCtor::Bool, | 647 | BuiltinType::Bool => TypeCtor::Bool, |
645 | BuiltinType::Str => TypeCtor::Str, | 648 | BuiltinType::Str => TypeCtor::Str, |
646 | BuiltinType::Int(ty) => TypeCtor::Int(ty.into()), | 649 | BuiltinType::Int { signedness, bitness } => { |
647 | BuiltinType::Float(ty) => TypeCtor::Float(ty.into()), | 650 | TypeCtor::Int(IntTy { signedness, bitness }.into()) |
651 | } | ||
652 | BuiltinType::Float { bitness } => TypeCtor::Float(FloatTy { bitness }.into()), | ||
648 | }) | 653 | }) |
649 | } | 654 | } |
650 | 655 | ||
651 | fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig { | 656 | fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig { |
652 | let var_data = def.variant_data(db); | 657 | let struct_data = db.struct_data(def.id); |
653 | let fields = match var_data.fields() { | 658 | let fields = match struct_data.variant_data.fields() { |
654 | Some(fields) => fields, | 659 | Some(fields) => fields, |
655 | None => panic!("fn_sig_for_struct_constructor called on unit struct"), | 660 | None => panic!("fn_sig_for_struct_constructor called on unit struct"), |
656 | }; | 661 | }; |
@@ -665,8 +670,8 @@ fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig { | |||
665 | 670 | ||
666 | /// Build the type of a tuple struct constructor. | 671 | /// Build the type of a tuple struct constructor. |
667 | fn type_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> Ty { | 672 | fn type_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> Ty { |
668 | let var_data = def.variant_data(db); | 673 | let struct_data = db.struct_data(def.id); |
669 | if var_data.fields().is_none() { | 674 | if struct_data.variant_data.fields().is_none() { |
670 | return type_for_adt(db, def); // Unit struct | 675 | return type_for_adt(db, def); // Unit struct |
671 | } | 676 | } |
672 | let generics = def.generic_params(db); | 677 | let generics = def.generic_params(db); |