diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-31 07:55:15 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-31 07:55:15 +0000 |
commit | 7973c91281837bbb5c5a0bf3b1c71a5b52654b20 (patch) | |
tree | 8459ba446606dd0920a87de23276a8c5f80fd58a /crates/ra_hir_def | |
parent | 51092ee72aa87787a65645ccdf82d3cb5a015915 (diff) | |
parent | b20d37cb49536e19f6af57b00258f86eb8f19325 (diff) |
Merge #2140
2140: move builtin types to hir_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/builtin_type.rs | 63 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lib.rs | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/builtin_type.rs b/crates/ra_hir_def/src/builtin_type.rs new file mode 100644 index 000000000..12929caa9 --- /dev/null +++ b/crates/ra_hir_def/src/builtin_type.rs | |||
@@ -0,0 +1,63 @@ | |||
1 | //! This module defines built-in types. | ||
2 | //! | ||
3 | //! A peculiarity of built-in types is that they are always available and are | ||
4 | //! not associated with any particular crate. | ||
5 | |||
6 | use hir_expand::name::{self, Name}; | ||
7 | |||
8 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] | ||
9 | pub enum Signedness { | ||
10 | Signed, | ||
11 | Unsigned, | ||
12 | } | ||
13 | |||
14 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] | ||
15 | pub enum IntBitness { | ||
16 | Xsize, | ||
17 | X8, | ||
18 | X16, | ||
19 | X32, | ||
20 | X64, | ||
21 | X128, | ||
22 | } | ||
23 | |||
24 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] | ||
25 | pub enum FloatBitness { | ||
26 | X32, | ||
27 | X64, | ||
28 | } | ||
29 | |||
30 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
31 | pub enum BuiltinType { | ||
32 | Char, | ||
33 | Bool, | ||
34 | Str, | ||
35 | Int { signedness: Signedness, bitness: IntBitness }, | ||
36 | Float { bitness: FloatBitness }, | ||
37 | } | ||
38 | |||
39 | impl BuiltinType { | ||
40 | #[rustfmt::skip] | ||
41 | pub const ALL: &'static [(Name, BuiltinType)] = &[ | ||
42 | (name::CHAR, BuiltinType::Char), | ||
43 | (name::BOOL, BuiltinType::Bool), | ||
44 | (name::STR, BuiltinType::Str ), | ||
45 | |||
46 | (name::ISIZE, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::Xsize }), | ||
47 | (name::I8, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X8 }), | ||
48 | (name::I16, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X16 }), | ||
49 | (name::I32, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X32 }), | ||
50 | (name::I64, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X64 }), | ||
51 | (name::I128, BuiltinType::Int { signedness: Signedness::Signed, bitness: IntBitness::X128 }), | ||
52 | |||
53 | (name::USIZE, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize }), | ||
54 | (name::U8, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X8 }), | ||
55 | (name::U16, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X16 }), | ||
56 | (name::U32, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X32 }), | ||
57 | (name::U64, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X64 }), | ||
58 | (name::U128, BuiltinType::Int { signedness: Signedness::Unsigned, bitness: IntBitness::X128 }), | ||
59 | |||
60 | (name::F32, BuiltinType::Float { bitness: FloatBitness::X32 }), | ||
61 | (name::F64, BuiltinType::Float { bitness: FloatBitness::X64 }), | ||
62 | ]; | ||
63 | } | ||
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 7a6c7b301..8cbff673c 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs | |||
@@ -11,6 +11,7 @@ pub mod db; | |||
11 | pub mod attr; | 11 | pub mod attr; |
12 | pub mod path; | 12 | pub mod path; |
13 | pub mod type_ref; | 13 | pub mod type_ref; |
14 | pub mod builtin_type; | ||
14 | 15 | ||
15 | // FIXME: this should be private | 16 | // FIXME: this should be private |
16 | pub mod nameres; | 17 | pub mod nameres; |