aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/ty/lower.rs6
-rw-r--r--crates/ra_hir_def/src/builtin_type.rs47
2 files changed, 32 insertions, 21 deletions
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 1fed5025e..52d24e24d 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};
@@ -657,10 +657,10 @@ 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(BuiltinInt { signedness, bitness }) => {
661 TypeCtor::Int(IntTy { signedness, bitness }.into()) 661 TypeCtor::Int(IntTy { signedness, bitness }.into())
662 } 662 }
663 BuiltinType::Float { bitness } => TypeCtor::Float(FloatTy { bitness }.into()), 663 BuiltinType::Float(BuiltinFloat { bitness }) => TypeCtor::Float(FloatTy { bitness }.into()),
664 }) 664 })
665} 665}
666 666
diff --git a/crates/ra_hir_def/src/builtin_type.rs b/crates/ra_hir_def/src/builtin_type.rs
index 2ec0c83fe..996e86fd9 100644
--- a/crates/ra_hir_def/src/builtin_type.rs
+++ b/crates/ra_hir_def/src/builtin_type.rs
@@ -30,12 +30,23 @@ pub enum FloatBitness {
30} 30}
31 31
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub struct BuiltinInt {
34 pub signedness: Signedness,
35 pub bitness: IntBitness,
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
39pub struct BuiltinFloat {
40 pub bitness: FloatBitness,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
33pub enum BuiltinType { 44pub enum BuiltinType {
34 Char, 45 Char,
35 Bool, 46 Bool,
36 Str, 47 Str,
37 Int { signedness: Signedness, bitness: IntBitness }, 48 Int(BuiltinInt),
38 Float { bitness: FloatBitness }, 49 Float(BuiltinFloat),
39} 50}
40 51
41impl BuiltinType { 52impl BuiltinType {
@@ -45,22 +56,22 @@ impl BuiltinType {
45 (name::BOOL, BuiltinType::Bool), 56 (name::BOOL, BuiltinType::Bool),
46 (name::STR, BuiltinType::Str ), 57 (name::STR, BuiltinType::Str ),
47 58
48 (name::ISIZE, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::Xsize }), 59 (name::ISIZE, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::Xsize })),
49 (name::I8, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X8 }), 60 (name::I8, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::X8 })),
50 (name::I16, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X16 }), 61 (name::I16, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::X16 })),
51 (name::I32, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X32 }), 62 (name::I32, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::X32 })),
52 (name::I64, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X64 }), 63 (name::I64, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::X64 })),
53 (name::I128, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X128 }), 64 (name::I128, BuiltinType::Int(BuiltinInt { signedness: Signedness::Signed, bitness: IntBitness::X128 })),
54 65
55 (name::USIZE, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize }), 66 (name::USIZE, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize })),
56 (name::U8, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X8 }), 67 (name::U8, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::X8 })),
57 (name::U16, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X16 }), 68 (name::U16, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::X16 })),
58 (name::U32, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X32 }), 69 (name::U32, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::X32 })),
59 (name::U64, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X64 }), 70 (name::U64, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::X64 })),
60 (name::U128, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X128 }), 71 (name::U128, BuiltinType::Int(BuiltinInt { signedness: Signedness::Unsigned, bitness: IntBitness::X128 })),
61 72
62 (name::F32, BuiltinType::Float { bitness: FloatBitness::X32 }), 73 (name::F32, BuiltinType::Float(BuiltinFloat { bitness: FloatBitness::X32 })),
63 (name::F64, BuiltinType::Float { bitness: FloatBitness::X64 }), 74 (name::F64, BuiltinType::Float(BuiltinFloat { bitness: FloatBitness::X64 })),
64 ]; 75 ];
65} 76}
66 77
@@ -70,7 +81,7 @@ impl fmt::Display for BuiltinType {
70 BuiltinType::Char => "char", 81 BuiltinType::Char => "char",
71 BuiltinType::Bool => "bool", 82 BuiltinType::Bool => "bool",
72 BuiltinType::Str => "str", 83 BuiltinType::Str => "str",
73 BuiltinType::Int { signedness, bitness } => match (signedness, bitness) { 84 BuiltinType::Int(BuiltinInt { signedness, bitness }) => match (signedness, bitness) {
74 (Signedness::Signed, IntBitness::Xsize) => "isize", 85 (Signedness::Signed, IntBitness::Xsize) => "isize",
75 (Signedness::Signed, IntBitness::X8) => "i8", 86 (Signedness::Signed, IntBitness::X8) => "i8",
76 (Signedness::Signed, IntBitness::X16) => "i16", 87 (Signedness::Signed, IntBitness::X16) => "i16",
@@ -85,7 +96,7 @@ impl fmt::Display for BuiltinType {
85 (Signedness::Unsigned, IntBitness::X64) => "u64", 96 (Signedness::Unsigned, IntBitness::X64) => "u64",
86 (Signedness::Unsigned, IntBitness::X128) => "u128", 97 (Signedness::Unsigned, IntBitness::X128) => "u128",
87 }, 98 },
88 BuiltinType::Float { bitness } => match bitness { 99 BuiltinType::Float(BuiltinFloat { bitness }) => match bitness {
89 FloatBitness::X32 => "f32", 100 FloatBitness::X32 => "f32",
90 FloatBitness::X64 => "f64", 101 FloatBitness::X64 => "f64",
91 }, 102 },