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.rs40
1 files changed, 34 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 1fed5025e..1832fcf50 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -9,7 +9,7 @@ use std::iter;
9use std::sync::Arc; 9use std::sync::Arc;
10 10
11use hir_def::{ 11use hir_def::{
12 builtin_type::BuiltinType, 12 builtin_type::{BuiltinFloat, BuiltinInt, BuiltinType},
13 path::{GenericArg, PathSegment}, 13 path::{GenericArg, PathSegment},
14 type_ref::{TypeBound, TypeRef}, 14 type_ref::{TypeBound, TypeRef},
15}; 15};
@@ -25,7 +25,7 @@ use crate::{
25 generics::{GenericDef, WherePredicate}, 25 generics::{GenericDef, WherePredicate},
26 resolve::{Resolver, TypeNs}, 26 resolve::{Resolver, TypeNs},
27 ty::{ 27 ty::{
28 primitive::{FloatTy, IntTy}, 28 primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
29 Adt, 29 Adt,
30 }, 30 },
31 util::make_mut_slice, 31 util::make_mut_slice,
@@ -657,13 +657,41 @@ fn type_for_builtin(def: BuiltinType) -> Ty {
657 BuiltinType::Char => TypeCtor::Char, 657 BuiltinType::Char => TypeCtor::Char,
658 BuiltinType::Bool => TypeCtor::Bool, 658 BuiltinType::Bool => TypeCtor::Bool,
659 BuiltinType::Str => TypeCtor::Str, 659 BuiltinType::Str => TypeCtor::Str,
660 BuiltinType::Int { signedness, bitness } => { 660 BuiltinType::Int(t) => TypeCtor::Int(IntTy::from(t).into()),
661 TypeCtor::Int(IntTy { signedness, bitness }.into()) 661 BuiltinType::Float(t) => TypeCtor::Float(FloatTy::from(t).into()),
662 }
663 BuiltinType::Float { bitness } => TypeCtor::Float(FloatTy { bitness }.into()),
664 }) 662 })
665} 663}
666 664
665impl From<BuiltinInt> for IntTy {
666 fn from(t: BuiltinInt) -> Self {
667 IntTy { signedness: t.signedness, bitness: t.bitness }
668 }
669}
670
671impl From<BuiltinFloat> for FloatTy {
672 fn from(t: BuiltinFloat) -> Self {
673 FloatTy { bitness: t.bitness }
674 }
675}
676
677impl From<Option<BuiltinInt>> for UncertainIntTy {
678 fn from(t: Option<BuiltinInt>) -> Self {
679 match t {
680 None => UncertainIntTy::Unknown,
681 Some(t) => UncertainIntTy::Known(t.into()),
682 }
683 }
684}
685
686impl From<Option<BuiltinFloat>> for UncertainFloatTy {
687 fn from(t: Option<BuiltinFloat>) -> Self {
688 match t {
689 None => UncertainFloatTy::Unknown,
690 Some(t) => UncertainFloatTy::Known(t.into()),
691 }
692 }
693}
694
667fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig { 695fn fn_sig_for_struct_constructor(db: &impl HirDatabase, def: Struct) -> FnSig {
668 let struct_data = db.struct_data(def.id.into()); 696 let struct_data = db.struct_data(def.id.into());
669 let fields = match struct_data.variant_data.fields() { 697 let fields = match struct_data.variant_data.fields() {