diff options
author | Aleksey Kladov <[email protected]> | 2019-05-30 12:26:27 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-30 12:26:27 +0100 |
commit | 4e5b02966b068a9aecc9d47290e865b0d44ce9ce (patch) | |
tree | 7f015d5713fe66e2d1f6c4fb52c431e527d7c85c /crates/ra_hir | |
parent | e6545cc647829091dd5aae5753bd4f5302becab6 (diff) |
add list of builtin types
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 30 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres.rs | 2 |
2 files changed, 29 insertions, 3 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 3f77850dd..3053f5488 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -4,12 +4,12 @@ use ra_db::{CrateId, SourceRootId, Edition, FileId}; | |||
4 | use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc}; | 4 | use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | Name, AsName, AstId, Ty, HirFileId, Either, | 7 | Name, AsName, AstId, Ty, HirFileId, Either, KnownName, |
8 | HirDatabase, DefDatabase, | 8 | HirDatabase, DefDatabase, |
9 | type_ref::TypeRef, | 9 | type_ref::TypeRef, |
10 | nameres::{ModuleScope, Namespace, ImportId, CrateModuleId}, | 10 | nameres::{ModuleScope, Namespace, ImportId, CrateModuleId}, |
11 | expr::{Body, BodySourceMap, validation::ExprValidator}, | 11 | expr::{Body, BodySourceMap, validation::ExprValidator}, |
12 | ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy}}, | 12 | ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy, Signedness, IntBitness, FloatBitness}}, |
13 | adt::{EnumVariantId, StructFieldId, VariantDef}, | 13 | adt::{EnumVariantId, StructFieldId, VariantDef}, |
14 | generics::HasGenericParams, | 14 | generics::HasGenericParams, |
15 | docs::{Documentation, Docs, docs_from_ast}, | 15 | docs::{Documentation, Docs, docs_from_ast}, |
@@ -84,6 +84,32 @@ pub enum BuiltinType { | |||
84 | Float(FloatTy), | 84 | Float(FloatTy), |
85 | } | 85 | } |
86 | 86 | ||
87 | impl BuiltinType { | ||
88 | #[rustfmt::skip] | ||
89 | pub(crate) const ALL: &'static [(KnownName, BuiltinType)] = &[ | ||
90 | (KnownName::Char, BuiltinType::Char), | ||
91 | (KnownName::Bool, BuiltinType::Bool), | ||
92 | (KnownName::Str, BuiltinType::Str), | ||
93 | |||
94 | (KnownName::Isize, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::Xsize })), | ||
95 | (KnownName::I8, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X8 })), | ||
96 | (KnownName::I16, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X16 })), | ||
97 | (KnownName::I32, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X32 })), | ||
98 | (KnownName::I64, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X64 })), | ||
99 | (KnownName::I128, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X128 })), | ||
100 | |||
101 | (KnownName::Usize, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize })), | ||
102 | (KnownName::U8, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X8 })), | ||
103 | (KnownName::U16, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X16 })), | ||
104 | (KnownName::U32, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X32 })), | ||
105 | (KnownName::U64, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X64 })), | ||
106 | (KnownName::U128, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 })), | ||
107 | |||
108 | (KnownName::F32, BuiltinType::Float(FloatTy { bitness: FloatBitness::X32 })), | ||
109 | (KnownName::F64, BuiltinType::Float(FloatTy { bitness: FloatBitness::X32 })), | ||
110 | ]; | ||
111 | } | ||
112 | |||
87 | /// The defs which can be visible in the module. | 113 | /// The defs which can be visible in the module. |
88 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 114 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
89 | pub enum ModuleDef { | 115 | pub enum ModuleDef { |
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index 42dcac332..51a7b8b95 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -64,7 +64,7 @@ use ra_syntax::ast; | |||
64 | use ra_prof::profile; | 64 | use ra_prof::profile; |
65 | 65 | ||
66 | use crate::{ | 66 | use crate::{ |
67 | ModuleDef, Name, Crate, Module, MacroDef, | 67 | ModuleDef, Name, Crate, Module, MacroDef, KnownName, BuiltinType, |
68 | DefDatabase, Path, PathKind, HirFileId, Trait, | 68 | DefDatabase, Path, PathKind, HirFileId, Trait, |
69 | ids::MacroDefId, | 69 | ids::MacroDefId, |
70 | diagnostics::DiagnosticSink, | 70 | diagnostics::DiagnosticSink, |