aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-08 09:29:19 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-08 09:29:19 +0100
commit5b19825e376b67aabbe8d5b163bf69b1acd92f04 (patch)
treebdf8054c58b9dba7116473ae4b0a772851a27c0c /crates/ra_hir/src/code_model.rs
parenta4316d6c63486d718f4d2e56d151180ef40ff0a1 (diff)
parent09b72489dd085dadce94b454408d18a36abb1681 (diff)
Merge #1507
1507: Constify KnownName's r=matklad a=mominul Closes #1503 Co-authored-by: Muhammad Mominul Huque <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs50
1 files changed, 27 insertions, 23 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 6cf2c620d..805357662 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -19,6 +19,10 @@ use crate::{
19 TypeAliasId, 19 TypeAliasId,
20 }, 20 },
21 impl_block::ImplBlock, 21 impl_block::ImplBlock,
22 name::{
23 BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128, U16, U32, U64,
24 U8, USIZE,
25 },
22 nameres::{CrateModuleId, ImportId, ModuleScope, Namespace}, 26 nameres::{CrateModuleId, ImportId, ModuleScope, Namespace},
23 resolve::Resolver, 27 resolve::Resolver,
24 traits::{TraitData, TraitItem}, 28 traits::{TraitData, TraitItem},
@@ -28,7 +32,7 @@ use crate::{
28 }, 32 },
29 type_ref::Mutability, 33 type_ref::Mutability,
30 type_ref::TypeRef, 34 type_ref::TypeRef,
31 AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, KnownName, Name, Ty, 35 AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, Name, Ty,
32}; 36};
33 37
34/// hir::Crate describes a single crate. It's the main interface with which 38/// hir::Crate describes a single crate. It's the main interface with which
@@ -96,27 +100,27 @@ pub enum BuiltinType {
96 100
97impl BuiltinType { 101impl BuiltinType {
98 #[rustfmt::skip] 102 #[rustfmt::skip]
99 pub(crate) const ALL: &'static [(KnownName, BuiltinType)] = &[ 103 pub(crate) const ALL: &'static [(Name, BuiltinType)] = &[
100 (KnownName::Char, BuiltinType::Char), 104 (CHAR, BuiltinType::Char),
101 (KnownName::Bool, BuiltinType::Bool), 105 (BOOL, BuiltinType::Bool),
102 (KnownName::Str, BuiltinType::Str), 106 (STR, BuiltinType::Str),
103 107
104 (KnownName::Isize, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::Xsize })), 108 (ISIZE, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::Xsize })),
105 (KnownName::I8, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X8 })), 109 (I8, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X8 })),
106 (KnownName::I16, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X16 })), 110 (I16, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X16 })),
107 (KnownName::I32, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X32 })), 111 (I32, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X32 })),
108 (KnownName::I64, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X64 })), 112 (I64, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X64 })),
109 (KnownName::I128, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X128 })), 113 (I128, BuiltinType::Int(IntTy { signedness: Signedness::Signed, bitness: IntBitness::X128 })),
110 114
111 (KnownName::Usize, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize })), 115 (USIZE, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::Xsize })),
112 (KnownName::U8, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X8 })), 116 (U8, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X8 })),
113 (KnownName::U16, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X16 })), 117 (U16, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X16 })),
114 (KnownName::U32, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X32 })), 118 (U32, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X32 })),
115 (KnownName::U64, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X64 })), 119 (U64, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X64 })),
116 (KnownName::U128, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 })), 120 (U128, BuiltinType::Int(IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 })),
117 121
118 (KnownName::F32, BuiltinType::Float(FloatTy { bitness: FloatBitness::X32 })), 122 (F32, BuiltinType::Float(FloatTy { bitness: FloatBitness::X32 })),
119 (KnownName::F64, BuiltinType::Float(FloatTy { bitness: FloatBitness::X64 })), 123 (F64, BuiltinType::Float(FloatTy { bitness: FloatBitness::X64 })),
120 ]; 124 ];
121} 125}
122 126
@@ -560,7 +564,7 @@ impl FnData {
560 let self_type = if let Some(type_ref) = self_param.ascribed_type() { 564 let self_type = if let Some(type_ref) = self_param.ascribed_type() {
561 TypeRef::from_ast(type_ref) 565 TypeRef::from_ast(type_ref)
562 } else { 566 } else {
563 let self_type = TypeRef::Path(Name::self_type().into()); 567 let self_type = TypeRef::Path(SELF_TYPE.into());
564 match self_param.kind() { 568 match self_param.kind() {
565 ast::SelfParamKind::Owned => self_type, 569 ast::SelfParamKind::Owned => self_type,
566 ast::SelfParamKind::Ref => { 570 ast::SelfParamKind::Ref => {