diff options
author | Lukas Wirth <[email protected]> | 2021-02-28 09:58:34 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-02-28 10:06:37 +0000 |
commit | 7c2dd85a32e320fd412a720ea5b847c66bf246ae (patch) | |
tree | fc5fb1d9ae0ae59f4d7eafe68720005d095bd360 /crates/hir_ty | |
parent | 5183c9f08345c664237ae138e86f96ff46714f15 (diff) |
Use chalk_ir::Scalar directly
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/display.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 16 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 24 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/primitive.rs | 147 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 64 |
6 files changed, 78 insertions, 197 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index cfe9cedb0..b4801cb21 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -3,9 +3,9 @@ | |||
3 | use std::{borrow::Cow, fmt}; | 3 | use std::{borrow::Cow, fmt}; |
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | db::HirDatabase, utils::generics, ApplicationTy, CallableDefId, FnSig, GenericPredicate, | 6 | db::HirDatabase, primitive, utils::generics, ApplicationTy, CallableDefId, FnSig, |
7 | Lifetime, Obligation, OpaqueTy, OpaqueTyId, ProjectionTy, Scalar, Substs, TraitRef, Ty, | 7 | GenericPredicate, Lifetime, Obligation, OpaqueTy, OpaqueTyId, ProjectionTy, Scalar, Substs, |
8 | TypeCtor, | 8 | TraitRef, Ty, TypeCtor, |
9 | }; | 9 | }; |
10 | use arrayvec::ArrayVec; | 10 | use arrayvec::ArrayVec; |
11 | use hir_def::{ | 11 | use hir_def::{ |
@@ -244,9 +244,11 @@ impl HirDisplay for ApplicationTy { | |||
244 | match self.ctor { | 244 | match self.ctor { |
245 | TypeCtor::Scalar(Scalar::Bool) => write!(f, "bool")?, | 245 | TypeCtor::Scalar(Scalar::Bool) => write!(f, "bool")?, |
246 | TypeCtor::Scalar(Scalar::Char) => write!(f, "char")?, | 246 | TypeCtor::Scalar(Scalar::Char) => write!(f, "char")?, |
247 | TypeCtor::Scalar(Scalar::Float(t)) => write!(f, "{}", t)?, | 247 | TypeCtor::Scalar(Scalar::Float(t)) => { |
248 | TypeCtor::Scalar(Scalar::Int(t)) => write!(f, "{}", t)?, | 248 | write!(f, "{}", primitive::float_ty_to_string(t))? |
249 | TypeCtor::Scalar(Scalar::Uint(t)) => write!(f, "{}", t)?, | 249 | } |
250 | TypeCtor::Scalar(Scalar::Int(t)) => write!(f, "{}", primitive::int_ty_to_string(t))?, | ||
251 | TypeCtor::Scalar(Scalar::Uint(t)) => write!(f, "{}", primitive::uint_ty_to_string(t))?, | ||
250 | TypeCtor::Str => write!(f, "str")?, | 252 | TypeCtor::Str => write!(f, "str")?, |
251 | TypeCtor::Slice => { | 253 | TypeCtor::Slice => { |
252 | let t = self.parameters.as_single(); | 254 | let t = self.parameters.as_single(); |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index c25f3f34b..3fec0e431 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -15,7 +15,7 @@ use test_utils::mark; | |||
15 | 15 | ||
16 | use crate::{ | 16 | use crate::{ |
17 | autoderef, method_resolution, op, | 17 | autoderef, method_resolution, op, |
18 | primitive::UintTy, | 18 | primitive::{self, UintTy}, |
19 | traits::{FnTrait, InEnvironment}, | 19 | traits::{FnTrait, InEnvironment}, |
20 | utils::{generics, variant_data, Generics}, | 20 | utils::{generics, variant_data, Generics}, |
21 | ApplicationTy, Binders, CallableDefId, InferTy, Mutability, Obligation, OpaqueTyId, Rawness, | 21 | ApplicationTy, Binders, CallableDefId, InferTy, Mutability, Obligation, OpaqueTyId, Rawness, |
@@ -730,17 +730,21 @@ impl<'a> InferenceContext<'a> { | |||
730 | } | 730 | } |
731 | Literal::Char(..) => Ty::simple(TypeCtor::Scalar(Scalar::Char)), | 731 | Literal::Char(..) => Ty::simple(TypeCtor::Scalar(Scalar::Char)), |
732 | Literal::Int(_v, ty) => match ty { | 732 | Literal::Int(_v, ty) => match ty { |
733 | Some(int_ty) => Ty::simple(TypeCtor::Scalar(Scalar::Int((*int_ty).into()))), | 733 | Some(int_ty) => Ty::simple(TypeCtor::Scalar(Scalar::Int( |
734 | primitive::int_ty_from_builtin(*int_ty), | ||
735 | ))), | ||
734 | None => self.table.new_integer_var(), | 736 | None => self.table.new_integer_var(), |
735 | }, | 737 | }, |
736 | Literal::Uint(_v, ty) => match ty { | 738 | Literal::Uint(_v, ty) => match ty { |
737 | Some(int_ty) => Ty::simple(TypeCtor::Scalar(Scalar::Uint((*int_ty).into()))), | 739 | Some(int_ty) => Ty::simple(TypeCtor::Scalar(Scalar::Uint( |
740 | primitive::uint_ty_from_builtin(*int_ty), | ||
741 | ))), | ||
738 | None => self.table.new_integer_var(), | 742 | None => self.table.new_integer_var(), |
739 | }, | 743 | }, |
740 | Literal::Float(_v, ty) => match ty { | 744 | Literal::Float(_v, ty) => match ty { |
741 | Some(float_ty) => { | 745 | Some(float_ty) => Ty::simple(TypeCtor::Scalar(Scalar::Float( |
742 | Ty::simple(TypeCtor::Scalar(Scalar::Float((*float_ty).into()))) | 746 | primitive::float_ty_from_builtin(*float_ty), |
743 | } | 747 | ))), |
744 | None => self.table.new_float_var(), | 748 | None => self.table.new_float_var(), |
745 | }, | 749 | }, |
746 | }, | 750 | }, |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 2a45479a8..676519594 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -38,7 +38,6 @@ use itertools::Itertools; | |||
38 | use crate::{ | 38 | use crate::{ |
39 | db::HirDatabase, | 39 | db::HirDatabase, |
40 | display::HirDisplay, | 40 | display::HirDisplay, |
41 | primitive::{FloatTy, IntTy, UintTy}, | ||
42 | utils::{generics, make_mut_slice, Generics}, | 41 | utils::{generics, make_mut_slice, Generics}, |
43 | }; | 42 | }; |
44 | 43 | ||
@@ -50,7 +49,7 @@ pub use lower::{ | |||
50 | }; | 49 | }; |
51 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; | 50 | pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; |
52 | 51 | ||
53 | pub use chalk_ir::{BoundVar, DebruijnIndex}; | 52 | pub use chalk_ir::{BoundVar, DebruijnIndex, Scalar}; |
54 | 53 | ||
55 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 54 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
56 | pub enum Lifetime { | 55 | pub enum Lifetime { |
@@ -58,17 +57,6 @@ pub enum Lifetime { | |||
58 | Static, | 57 | Static, |
59 | } | 58 | } |
60 | 59 | ||
61 | /// Types of scalar values. | ||
62 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
63 | #[allow(missing_docs)] | ||
64 | pub enum Scalar { | ||
65 | Bool, | ||
66 | Char, | ||
67 | Int(IntTy), | ||
68 | Uint(UintTy), | ||
69 | Float(FloatTy), | ||
70 | } | ||
71 | |||
72 | /// A type constructor or type name: this might be something like the primitive | 60 | /// A type constructor or type name: this might be something like the primitive |
73 | /// type `bool`, a struct like `Vec`, or things like function pointers or | 61 | /// type `bool`, a struct like `Vec`, or things like function pointers or |
74 | /// tuples. | 62 | /// tuples. |
@@ -736,9 +724,13 @@ impl Ty { | |||
736 | BuiltinType::Char => TypeCtor::Scalar(Scalar::Char), | 724 | BuiltinType::Char => TypeCtor::Scalar(Scalar::Char), |
737 | BuiltinType::Bool => TypeCtor::Scalar(Scalar::Bool), | 725 | BuiltinType::Bool => TypeCtor::Scalar(Scalar::Bool), |
738 | BuiltinType::Str => TypeCtor::Str, | 726 | BuiltinType::Str => TypeCtor::Str, |
739 | BuiltinType::Int(t) => TypeCtor::Scalar(Scalar::Int(t.into())), | 727 | BuiltinType::Int(t) => TypeCtor::Scalar(Scalar::Int(primitive::int_ty_from_builtin(t))), |
740 | BuiltinType::Uint(t) => TypeCtor::Scalar(Scalar::Uint(t.into())), | 728 | BuiltinType::Uint(t) => { |
741 | BuiltinType::Float(t) => TypeCtor::Scalar(Scalar::Float(t.into())), | 729 | TypeCtor::Scalar(Scalar::Uint(primitive::uint_ty_from_builtin(t))) |
730 | } | ||
731 | BuiltinType::Float(t) => { | ||
732 | TypeCtor::Scalar(Scalar::Float(primitive::float_ty_from_builtin(t))) | ||
733 | } | ||
742 | }) | 734 | }) |
743 | } | 735 | } |
744 | 736 | ||
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 3c817701d..66d8de959 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -16,7 +16,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
16 | use crate::{ | 16 | use crate::{ |
17 | autoderef, | 17 | autoderef, |
18 | db::HirDatabase, | 18 | db::HirDatabase, |
19 | primitive::{FloatTy, IntTy, UintTy}, | 19 | primitive::{self, FloatTy, IntTy, UintTy}, |
20 | utils::all_super_traits, | 20 | utils::all_super_traits, |
21 | ApplicationTy, Canonical, DebruijnIndex, InEnvironment, Scalar, Substs, TraitEnvironment, | 21 | ApplicationTy, Canonical, DebruijnIndex, InEnvironment, Scalar, Substs, TraitEnvironment, |
22 | TraitRef, Ty, TyKind, TypeCtor, TypeWalk, | 22 | TraitRef, Ty, TyKind, TypeCtor, TypeWalk, |
@@ -225,8 +225,12 @@ impl Ty { | |||
225 | FloatTy::F32 => lang_item_crate!("f32", "f32_runtime"), | 225 | FloatTy::F32 => lang_item_crate!("f32", "f32_runtime"), |
226 | FloatTy::F64 => lang_item_crate!("f64", "f64_runtime"), | 226 | FloatTy::F64 => lang_item_crate!("f64", "f64_runtime"), |
227 | }, | 227 | }, |
228 | TypeCtor::Scalar(Scalar::Int(t)) => lang_item_crate!(t.ty_to_string()), | 228 | TypeCtor::Scalar(Scalar::Int(t)) => { |
229 | TypeCtor::Scalar(Scalar::Uint(t)) => lang_item_crate!(t.ty_to_string()), | 229 | lang_item_crate!(primitive::int_ty_to_string(t)) |
230 | } | ||
231 | TypeCtor::Scalar(Scalar::Uint(t)) => { | ||
232 | lang_item_crate!(primitive::uint_ty_to_string(t)) | ||
233 | } | ||
230 | TypeCtor::Str => lang_item_crate!("str_alloc", "str"), | 234 | TypeCtor::Str => lang_item_crate!("str_alloc", "str"), |
231 | TypeCtor::Slice => lang_item_crate!("slice_alloc", "slice"), | 235 | TypeCtor::Slice => lang_item_crate!("slice_alloc", "slice"), |
232 | TypeCtor::RawPtr(Mutability::Shared) => lang_item_crate!("const_ptr"), | 236 | TypeCtor::RawPtr(Mutability::Shared) => lang_item_crate!("const_ptr"), |
diff --git a/crates/hir_ty/src/primitive.rs b/crates/hir_ty/src/primitive.rs index e727c9581..2449addfb 100644 --- a/crates/hir_ty/src/primitive.rs +++ b/crates/hir_ty/src/primitive.rs | |||
@@ -3,128 +3,63 @@ | |||
3 | //! * during type inference, they can be uncertain (ie, `let x = 92;`) | 3 | //! * during type inference, they can be uncertain (ie, `let x = 92;`) |
4 | //! * they don't belong to any particular crate. | 4 | //! * they don't belong to any particular crate. |
5 | 5 | ||
6 | use std::fmt; | 6 | pub use chalk_ir::{FloatTy, IntTy, UintTy}; |
7 | |||
8 | pub use hir_def::builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}; | 7 | pub use hir_def::builtin_type::{BuiltinFloat, BuiltinInt, BuiltinUint}; |
9 | 8 | ||
10 | /// Different signed int types. | 9 | pub fn int_ty_to_string(ty: IntTy) -> &'static str { |
11 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | 10 | match ty { |
12 | pub enum IntTy { | 11 | IntTy::Isize => "isize", |
13 | Isize, | 12 | IntTy::I8 => "i8", |
14 | I8, | 13 | IntTy::I16 => "i16", |
15 | I16, | 14 | IntTy::I32 => "i32", |
16 | I32, | 15 | IntTy::I64 => "i64", |
17 | I64, | 16 | IntTy::I128 => "i128", |
18 | I128, | ||
19 | } | ||
20 | |||
21 | /// Different unsigned int types. | ||
22 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
23 | pub enum UintTy { | ||
24 | Usize, | ||
25 | U8, | ||
26 | U16, | ||
27 | U32, | ||
28 | U64, | ||
29 | U128, | ||
30 | } | ||
31 | |||
32 | impl fmt::Display for IntTy { | ||
33 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
34 | write!(f, "{}", self.ty_to_string()) | ||
35 | } | ||
36 | } | ||
37 | |||
38 | impl IntTy { | ||
39 | pub fn ty_to_string(self) -> &'static str { | ||
40 | match self { | ||
41 | IntTy::Isize => "isize", | ||
42 | IntTy::I8 => "i8", | ||
43 | IntTy::I16 => "i16", | ||
44 | IntTy::I32 => "i32", | ||
45 | IntTy::I64 => "i64", | ||
46 | IntTy::I128 => "i128", | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | |||
51 | impl fmt::Display for UintTy { | ||
52 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
53 | write!(f, "{}", self.ty_to_string()) | ||
54 | } | ||
55 | } | ||
56 | |||
57 | impl UintTy { | ||
58 | pub fn ty_to_string(self) -> &'static str { | ||
59 | match self { | ||
60 | UintTy::Usize => "usize", | ||
61 | UintTy::U8 => "u8", | ||
62 | UintTy::U16 => "u16", | ||
63 | UintTy::U32 => "u32", | ||
64 | UintTy::U64 => "u64", | ||
65 | UintTy::U128 => "u128", | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | |||
70 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
71 | pub enum FloatTy { | ||
72 | F32, | ||
73 | F64, | ||
74 | } | ||
75 | |||
76 | impl fmt::Debug for FloatTy { | ||
77 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
78 | fmt::Display::fmt(self, f) | ||
79 | } | 17 | } |
80 | } | 18 | } |
81 | 19 | ||
82 | impl fmt::Display for FloatTy { | 20 | pub fn uint_ty_to_string(ty: UintTy) -> &'static str { |
83 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 21 | match ty { |
84 | write!(f, "{}", self.ty_to_string()) | 22 | UintTy::Usize => "usize", |
23 | UintTy::U8 => "u8", | ||
24 | UintTy::U16 => "u16", | ||
25 | UintTy::U32 => "u32", | ||
26 | UintTy::U64 => "u64", | ||
27 | UintTy::U128 => "u128", | ||
85 | } | 28 | } |
86 | } | 29 | } |
87 | 30 | ||
88 | impl FloatTy { | 31 | pub fn float_ty_to_string(ty: FloatTy) -> &'static str { |
89 | pub fn ty_to_string(self) -> &'static str { | 32 | match ty { |
90 | match self { | 33 | FloatTy::F32 => "f32", |
91 | FloatTy::F32 => "f32", | 34 | FloatTy::F64 => "f64", |
92 | FloatTy::F64 => "f64", | ||
93 | } | ||
94 | } | 35 | } |
95 | } | 36 | } |
96 | 37 | ||
97 | impl From<BuiltinInt> for IntTy { | 38 | pub(super) fn int_ty_from_builtin(t: BuiltinInt) -> IntTy { |
98 | fn from(t: BuiltinInt) -> Self { | 39 | match t { |
99 | match t { | 40 | BuiltinInt::Isize => IntTy::Isize, |
100 | BuiltinInt::Isize => Self::Isize, | 41 | BuiltinInt::I8 => IntTy::I8, |
101 | BuiltinInt::I8 => Self::I8, | 42 | BuiltinInt::I16 => IntTy::I16, |
102 | BuiltinInt::I16 => Self::I16, | 43 | BuiltinInt::I32 => IntTy::I32, |
103 | BuiltinInt::I32 => Self::I32, | 44 | BuiltinInt::I64 => IntTy::I64, |
104 | BuiltinInt::I64 => Self::I64, | 45 | BuiltinInt::I128 => IntTy::I128, |
105 | BuiltinInt::I128 => Self::I128, | ||
106 | } | ||
107 | } | 46 | } |
108 | } | 47 | } |
109 | 48 | ||
110 | impl From<BuiltinUint> for UintTy { | 49 | pub(super) fn uint_ty_from_builtin(t: BuiltinUint) -> UintTy { |
111 | fn from(t: BuiltinUint) -> Self { | 50 | match t { |
112 | match t { | 51 | BuiltinUint::Usize => UintTy::Usize, |
113 | BuiltinUint::Usize => Self::Usize, | 52 | BuiltinUint::U8 => UintTy::U8, |
114 | BuiltinUint::U8 => Self::U8, | 53 | BuiltinUint::U16 => UintTy::U16, |
115 | BuiltinUint::U16 => Self::U16, | 54 | BuiltinUint::U32 => UintTy::U32, |
116 | BuiltinUint::U32 => Self::U32, | 55 | BuiltinUint::U64 => UintTy::U64, |
117 | BuiltinUint::U64 => Self::U64, | 56 | BuiltinUint::U128 => UintTy::U128, |
118 | BuiltinUint::U128 => Self::U128, | ||
119 | } | ||
120 | } | 57 | } |
121 | } | 58 | } |
122 | 59 | ||
123 | impl From<BuiltinFloat> for FloatTy { | 60 | pub(super) fn float_ty_from_builtin(t: BuiltinFloat) -> FloatTy { |
124 | fn from(t: BuiltinFloat) -> Self { | 61 | match t { |
125 | match t { | 62 | BuiltinFloat::F32 => FloatTy::F32, |
126 | BuiltinFloat::F32 => Self::F32, | 63 | BuiltinFloat::F64 => FloatTy::F64, |
127 | BuiltinFloat::F64 => Self::F64, | ||
128 | } | ||
129 | } | 64 | } |
130 | } | 65 | } |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 0e9fc3265..5a3cb7906 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -14,7 +14,7 @@ use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, Type | |||
14 | 14 | ||
15 | use crate::{ | 15 | use crate::{ |
16 | db::HirDatabase, | 16 | db::HirDatabase, |
17 | primitive::{FloatTy, IntTy, UintTy}, | 17 | primitive::UintTy, |
18 | traits::{Canonical, Obligation}, | 18 | traits::{Canonical, Obligation}, |
19 | ApplicationTy, CallableDefId, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, | 19 | ApplicationTy, CallableDefId, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, |
20 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, TyKind, | 20 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, TyKind, |
@@ -64,31 +64,7 @@ impl ToChalk for Ty { | |||
64 | chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner) | 64 | chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner) |
65 | } | 65 | } |
66 | 66 | ||
67 | TypeCtor::Scalar(scalar) => chalk_ir::TyKind::Scalar(match scalar { | 67 | TypeCtor::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), |
68 | Scalar::Bool => chalk_ir::Scalar::Bool, | ||
69 | Scalar::Char => chalk_ir::Scalar::Char, | ||
70 | Scalar::Int(it) => chalk_ir::Scalar::Int(match it { | ||
71 | IntTy::Isize => chalk_ir::IntTy::Isize, | ||
72 | IntTy::I8 => chalk_ir::IntTy::I8, | ||
73 | IntTy::I16 => chalk_ir::IntTy::I16, | ||
74 | IntTy::I32 => chalk_ir::IntTy::I32, | ||
75 | IntTy::I64 => chalk_ir::IntTy::I64, | ||
76 | IntTy::I128 => chalk_ir::IntTy::I128, | ||
77 | }), | ||
78 | Scalar::Uint(it) => chalk_ir::Scalar::Uint(match it { | ||
79 | UintTy::Usize => chalk_ir::UintTy::Usize, | ||
80 | UintTy::U8 => chalk_ir::UintTy::U8, | ||
81 | UintTy::U16 => chalk_ir::UintTy::U16, | ||
82 | UintTy::U32 => chalk_ir::UintTy::U32, | ||
83 | UintTy::U64 => chalk_ir::UintTy::U64, | ||
84 | UintTy::U128 => chalk_ir::UintTy::U128, | ||
85 | }), | ||
86 | Scalar::Float(it) => chalk_ir::Scalar::Float(match it { | ||
87 | FloatTy::F32 => chalk_ir::FloatTy::F32, | ||
88 | FloatTy::F64 => chalk_ir::FloatTy::F64, | ||
89 | }), | ||
90 | }) | ||
91 | .intern(&Interner), | ||
92 | 68 | ||
93 | TypeCtor::Tuple { cardinality } => { | 69 | TypeCtor::Tuple { cardinality } => { |
94 | let substitution = apply_ty.parameters.to_chalk(db); | 70 | let substitution = apply_ty.parameters.to_chalk(db); |
@@ -232,38 +208,7 @@ impl ToChalk for Ty { | |||
232 | apply_ty_from_chalk(db, TypeCtor::OpaqueType(from_chalk(db, opaque_type_id)), subst) | 208 | apply_ty_from_chalk(db, TypeCtor::OpaqueType(from_chalk(db, opaque_type_id)), subst) |
233 | } | 209 | } |
234 | 210 | ||
235 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Bool) => { | 211 | chalk_ir::TyKind::Scalar(scalar) => Ty::simple(TypeCtor::Scalar(scalar)), |
236 | Ty::simple(TypeCtor::Scalar(Scalar::Bool)) | ||
237 | } | ||
238 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Char) => { | ||
239 | Ty::simple(TypeCtor::Scalar(Scalar::Char)) | ||
240 | } | ||
241 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(int_ty)) => { | ||
242 | Ty::simple(TypeCtor::Scalar(Scalar::Int(match int_ty { | ||
243 | chalk_ir::IntTy::Isize => IntTy::Isize, | ||
244 | chalk_ir::IntTy::I8 => IntTy::I8, | ||
245 | chalk_ir::IntTy::I16 => IntTy::I16, | ||
246 | chalk_ir::IntTy::I32 => IntTy::I32, | ||
247 | chalk_ir::IntTy::I64 => IntTy::I64, | ||
248 | chalk_ir::IntTy::I128 => IntTy::I128, | ||
249 | }))) | ||
250 | } | ||
251 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(int_ty)) => { | ||
252 | Ty::simple(TypeCtor::Scalar(Scalar::Uint(match int_ty { | ||
253 | chalk_ir::UintTy::Usize => UintTy::Usize, | ||
254 | chalk_ir::UintTy::U8 => UintTy::U8, | ||
255 | chalk_ir::UintTy::U16 => UintTy::U16, | ||
256 | chalk_ir::UintTy::U32 => UintTy::U32, | ||
257 | chalk_ir::UintTy::U64 => UintTy::U64, | ||
258 | chalk_ir::UintTy::U128 => UintTy::U128, | ||
259 | }))) | ||
260 | } | ||
261 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Float(float_ty)) => { | ||
262 | Ty::simple(TypeCtor::Scalar(Scalar::Float(match float_ty { | ||
263 | chalk_ir::FloatTy::F32 => FloatTy::F32, | ||
264 | chalk_ir::FloatTy::F64 => FloatTy::F64, | ||
265 | }))) | ||
266 | } | ||
267 | chalk_ir::TyKind::Tuple(cardinality, subst) => { | 212 | chalk_ir::TyKind::Tuple(cardinality, subst) => { |
268 | apply_ty_from_chalk(db, TypeCtor::Tuple { cardinality: cardinality as u16 }, subst) | 213 | apply_ty_from_chalk(db, TypeCtor::Tuple { cardinality: cardinality as u16 }, subst) |
269 | } | 214 | } |
@@ -321,8 +266,7 @@ fn ref_to_chalk( | |||
321 | /// fake constant here, because Chalks built-in logic may expect it to be there. | 266 | /// fake constant here, because Chalks built-in logic may expect it to be there. |
322 | fn array_to_chalk(db: &dyn HirDatabase, subst: Substs) -> chalk_ir::Ty<Interner> { | 267 | fn array_to_chalk(db: &dyn HirDatabase, subst: Substs) -> chalk_ir::Ty<Interner> { |
323 | let arg = subst[0].clone().to_chalk(db); | 268 | let arg = subst[0].clone().to_chalk(db); |
324 | let usize_ty = | 269 | let usize_ty = chalk_ir::TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(&Interner); |
325 | chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(chalk_ir::UintTy::Usize)).intern(&Interner); | ||
326 | let const_ = chalk_ir::ConstData { | 270 | let const_ = chalk_ir::ConstData { |
327 | ty: usize_ty, | 271 | ty: usize_ty, |
328 | value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: () }), | 272 | value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: () }), |