diff options
Diffstat (limited to 'crates/hir_ty/src/method_resolution.rs')
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 90 |
1 files changed, 26 insertions, 64 deletions
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index b3d1fe9a4..3c817701d 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -7,11 +7,8 @@ use std::{iter, sync::Arc}; | |||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use base_db::CrateId; | 8 | use base_db::CrateId; |
9 | use hir_def::{ | 9 | use hir_def::{ |
10 | builtin_type::{IntBitness, Signedness}, | 10 | lang_item::LangItemTarget, type_ref::Mutability, AssocContainerId, AssocItemId, FunctionId, |
11 | lang_item::LangItemTarget, | 11 | GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId, |
12 | type_ref::Mutability, | ||
13 | AssocContainerId, AssocItemId, FunctionId, GenericDefId, HasModule, ImplId, Lookup, ModuleId, | ||
14 | TraitId, | ||
15 | }; | 12 | }; |
16 | use hir_expand::name::Name; | 13 | use hir_expand::name::Name; |
17 | use rustc_hash::{FxHashMap, FxHashSet}; | 14 | use rustc_hash::{FxHashMap, FxHashSet}; |
@@ -19,10 +16,10 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
19 | use crate::{ | 16 | use crate::{ |
20 | autoderef, | 17 | autoderef, |
21 | db::HirDatabase, | 18 | db::HirDatabase, |
22 | primitive::{FloatBitness, FloatTy, IntTy}, | 19 | primitive::{FloatTy, IntTy, UintTy}, |
23 | utils::all_super_traits, | 20 | utils::all_super_traits, |
24 | ApplicationTy, Canonical, DebruijnIndex, InEnvironment, Substs, TraitEnvironment, TraitRef, Ty, | 21 | ApplicationTy, Canonical, DebruijnIndex, InEnvironment, Scalar, Substs, TraitEnvironment, |
25 | TyKind, TypeCtor, TypeWalk, | 22 | TraitRef, Ty, TyKind, TypeCtor, TypeWalk, |
26 | }; | 23 | }; |
27 | 24 | ||
28 | /// This is used as a key for indexing impls. | 25 | /// This is used as a key for indexing impls. |
@@ -46,59 +43,23 @@ impl TyFingerprint { | |||
46 | } | 43 | } |
47 | 44 | ||
48 | pub(crate) const ALL_INT_FPS: [TyFingerprint; 12] = [ | 45 | pub(crate) const ALL_INT_FPS: [TyFingerprint; 12] = [ |
49 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | 46 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::I8))), |
50 | signedness: Signedness::Unsigned, | 47 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::I16))), |
51 | bitness: IntBitness::X8, | 48 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::I32))), |
52 | })), | 49 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::I64))), |
53 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | 50 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::I128))), |
54 | signedness: Signedness::Unsigned, | 51 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Int(IntTy::Isize))), |
55 | bitness: IntBitness::X16, | 52 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::U8))), |
56 | })), | 53 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::U16))), |
57 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | 54 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::U32))), |
58 | signedness: Signedness::Unsigned, | 55 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::U64))), |
59 | bitness: IntBitness::X32, | 56 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::U128))), |
60 | })), | 57 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Uint(UintTy::Usize))), |
61 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
62 | signedness: Signedness::Unsigned, | ||
63 | bitness: IntBitness::X64, | ||
64 | })), | ||
65 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
66 | signedness: Signedness::Unsigned, | ||
67 | bitness: IntBitness::X128, | ||
68 | })), | ||
69 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
70 | signedness: Signedness::Unsigned, | ||
71 | bitness: IntBitness::Xsize, | ||
72 | })), | ||
73 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
74 | signedness: Signedness::Signed, | ||
75 | bitness: IntBitness::X8, | ||
76 | })), | ||
77 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
78 | signedness: Signedness::Signed, | ||
79 | bitness: IntBitness::X16, | ||
80 | })), | ||
81 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
82 | signedness: Signedness::Signed, | ||
83 | bitness: IntBitness::X32, | ||
84 | })), | ||
85 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
86 | signedness: Signedness::Signed, | ||
87 | bitness: IntBitness::X64, | ||
88 | })), | ||
89 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
90 | signedness: Signedness::Signed, | ||
91 | bitness: IntBitness::X128, | ||
92 | })), | ||
93 | TyFingerprint::Apply(TypeCtor::Int(IntTy { | ||
94 | signedness: Signedness::Signed, | ||
95 | bitness: IntBitness::Xsize, | ||
96 | })), | ||
97 | ]; | 58 | ]; |
98 | 59 | ||
99 | pub(crate) const ALL_FLOAT_FPS: [TyFingerprint; 2] = [ | 60 | pub(crate) const ALL_FLOAT_FPS: [TyFingerprint; 2] = [ |
100 | TyFingerprint::Apply(TypeCtor::Float(FloatTy { bitness: FloatBitness::X32 })), | 61 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Float(FloatTy::F32))), |
101 | TyFingerprint::Apply(TypeCtor::Float(FloatTy { bitness: FloatBitness::X64 })), | 62 | TyFingerprint::Apply(TypeCtor::Scalar(Scalar::Float(FloatTy::F64))), |
102 | ]; | 63 | ]; |
103 | 64 | ||
104 | /// Trait impls defined or available in some crate. | 65 | /// Trait impls defined or available in some crate. |
@@ -257,14 +218,15 @@ impl Ty { | |||
257 | TypeCtor::ForeignType(type_alias_id) => { | 218 | TypeCtor::ForeignType(type_alias_id) => { |
258 | return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast())); | 219 | return mod_to_crate_ids(type_alias_id.lookup(db.upcast()).module(db.upcast())); |
259 | } | 220 | } |
260 | TypeCtor::Bool => lang_item_crate!("bool"), | 221 | TypeCtor::Scalar(Scalar::Bool) => lang_item_crate!("bool"), |
261 | TypeCtor::Char => lang_item_crate!("char"), | 222 | TypeCtor::Scalar(Scalar::Char) => lang_item_crate!("char"), |
262 | TypeCtor::Float(f) => match f.bitness { | 223 | TypeCtor::Scalar(Scalar::Float(f)) => match f { |
263 | // There are two lang items: one in libcore (fXX) and one in libstd (fXX_runtime) | 224 | // There are two lang items: one in libcore (fXX) and one in libstd (fXX_runtime) |
264 | FloatBitness::X32 => lang_item_crate!("f32", "f32_runtime"), | 225 | FloatTy::F32 => lang_item_crate!("f32", "f32_runtime"), |
265 | FloatBitness::X64 => lang_item_crate!("f64", "f64_runtime"), | 226 | FloatTy::F64 => lang_item_crate!("f64", "f64_runtime"), |
266 | }, | 227 | }, |
267 | TypeCtor::Int(i) => lang_item_crate!(i.ty_to_string()), | 228 | TypeCtor::Scalar(Scalar::Int(t)) => lang_item_crate!(t.ty_to_string()), |
229 | TypeCtor::Scalar(Scalar::Uint(t)) => lang_item_crate!(t.ty_to_string()), | ||
268 | TypeCtor::Str => lang_item_crate!("str_alloc", "str"), | 230 | TypeCtor::Str => lang_item_crate!("str_alloc", "str"), |
269 | TypeCtor::Slice => lang_item_crate!("slice_alloc", "slice"), | 231 | TypeCtor::Slice => lang_item_crate!("slice_alloc", "slice"), |
270 | TypeCtor::RawPtr(Mutability::Shared) => lang_item_crate!("const_ptr"), | 232 | TypeCtor::RawPtr(Mutability::Shared) => lang_item_crate!("const_ptr"), |