aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs48
1 files changed, 4 insertions, 44 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index a6ce23dd1..e0c6d6340 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -6,13 +6,11 @@ pub(crate) mod docs;
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use hir_def::{ 8use hir_def::{
9 builtin_type::BuiltinType,
9 type_ref::{Mutability, TypeRef}, 10 type_ref::{Mutability, TypeRef},
10 CrateModuleId, ModuleId, 11 CrateModuleId, ModuleId,
11}; 12};
12use hir_expand::name::{ 13use hir_expand::name::{self, AsName};
13 self, AsName, BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128, U16,
14 U32, U64, U8, USIZE,
15};
16use ra_db::{CrateId, Edition}; 14use ra_db::{CrateId, Edition};
17use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; 15use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
18 16
@@ -30,10 +28,7 @@ use crate::{
30 nameres::{ImportId, ModuleScope, Namespace}, 28 nameres::{ImportId, ModuleScope, Namespace},
31 resolve::{Resolver, Scope, TypeNs}, 29 resolve::{Resolver, Scope, TypeNs},
32 traits::TraitData, 30 traits::TraitData,
33 ty::{ 31 ty::{InferenceResult, TraitRef},
34 primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
35 InferenceResult, TraitRef,
36 },
37 Either, HasSource, Name, Ty, 32 Either, HasSource, Name, Ty,
38}; 33};
39 34
@@ -87,41 +82,6 @@ pub struct Module {
87 pub(crate) id: ModuleId, 82 pub(crate) id: ModuleId,
88} 83}
89 84
90#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
91pub enum BuiltinType {
92 Char,
93 Bool,
94 Str,
95 Int(IntTy),
96 Float(FloatTy),
97}
98
99impl BuiltinType {
100 #[rustfmt::skip]
101 pub(crate) const ALL: &'static [(Name, BuiltinType)] = &[
102 (CHAR, BuiltinType::Char),
103 (BOOL, BuiltinType::Bool),
104 (STR, BuiltinType::Str),
105
106 (ISIZE, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::Xsize })),
107 (I8, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X8 })),
108 (I16, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X16 })),
109 (I32, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X32 })),
110 (I64, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X64 })),
111 (I128, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X128 })),
112
113 (USIZE, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize })),
114 (U8, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X8 })),
115 (U16, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X16 })),
116 (U32, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X32 })),
117 (U64, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X64 })),
118 (U128, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 })),
119
120 (F32, BuiltinType::Float(FloatTy { bitness: FloatBitness::X32 })),
121 (F64, BuiltinType::Float(FloatTy { bitness: FloatBitness::X64 })),
122 ];
123}
124
125/// The defs which can be visible in the module. 85/// The defs which can be visible in the module.
126#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 86#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
127pub enum ModuleDef { 87pub enum ModuleDef {
@@ -625,7 +585,7 @@ impl FnData {
625 let self_type = if let Some(type_ref) = self_param.ascribed_type() { 585 let self_type = if let Some(type_ref) = self_param.ascribed_type() {
626 TypeRef::from_ast(type_ref) 586 TypeRef::from_ast(type_ref)
627 } else { 587 } else {
628 let self_type = TypeRef::Path(SELF_TYPE.into()); 588 let self_type = TypeRef::Path(name::SELF_TYPE.into());
629 match self_param.kind() { 589 match self_param.kind() {
630 ast::SelfParamKind::Owned => self_type, 590 ast::SelfParamKind::Owned => self_type,
631 ast::SelfParamKind::Ref => { 591 ast::SelfParamKind::Ref => {