diff options
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index ad2ab560d..eb69344f6 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -5,18 +5,17 @@ | |||
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use hir_def::CrateModuleId; | ||
8 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
9 | 10 | ||
10 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; | 11 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; |
11 | use crate::{ | 12 | use crate::{ |
12 | db::HirDatabase, | 13 | db::HirDatabase, |
13 | impl_block::{ImplBlock, ImplId}, | 14 | impl_block::{ImplBlock, ImplId}, |
14 | nameres::CrateModuleId, | ||
15 | resolve::Resolver, | 15 | resolve::Resolver, |
16 | ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, | 16 | ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy}, |
17 | ty::{Ty, TypeCtor}, | 17 | ty::{Ty, TypeCtor}, |
18 | type_ref::Mutability, | 18 | AssocItem, Crate, Function, Module, Mutability, Name, Trait, |
19 | AssocItem, Crate, Function, Module, Name, Trait, | ||
20 | }; | 19 | }; |
21 | 20 | ||
22 | /// This is used as a key for indexing impls. | 21 | /// This is used as a key for indexing impls. |
@@ -50,7 +49,7 @@ impl CrateImplBlocks { | |||
50 | let fingerprint = TyFingerprint::for_impl(ty); | 49 | let fingerprint = TyFingerprint::for_impl(ty); |
51 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map( | 50 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map( |
52 | move |(module_id, impl_id)| { | 51 | move |(module_id, impl_id)| { |
53 | let module = Module { krate: self.krate, module_id: *module_id }; | 52 | let module = Module::new(self.krate, *module_id); |
54 | ImplBlock::from_id(module, *impl_id) | 53 | ImplBlock::from_id(module, *impl_id) |
55 | }, | 54 | }, |
56 | ) | 55 | ) |
@@ -62,7 +61,7 @@ impl CrateImplBlocks { | |||
62 | ) -> impl Iterator<Item = ImplBlock> + 'a { | 61 | ) -> impl Iterator<Item = ImplBlock> + 'a { |
63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( | 62 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( |
64 | move |(module_id, impl_id)| { | 63 | move |(module_id, impl_id)| { |
65 | let module = Module { krate: self.krate, module_id: *module_id }; | 64 | let module = Module::new(self.krate, *module_id); |
66 | ImplBlock::from_id(module, *impl_id) | 65 | ImplBlock::from_id(module, *impl_id) |
67 | }, | 66 | }, |
68 | ) | 67 | ) |
@@ -71,7 +70,7 @@ impl CrateImplBlocks { | |||
71 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { | 70 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { |
72 | self.impls.values().chain(self.impls_by_trait.values()).flat_map(|i| i.iter()).map( | 71 | self.impls.values().chain(self.impls_by_trait.values()).flat_map(|i| i.iter()).map( |
73 | move |(module_id, impl_id)| { | 72 | move |(module_id, impl_id)| { |
74 | let module = Module { krate: self.krate, module_id: *module_id }; | 73 | let module = Module::new(self.krate, *module_id); |
75 | ImplBlock::from_id(module, *impl_id) | 74 | ImplBlock::from_id(module, *impl_id) |
76 | }, | 75 | }, |
77 | ) | 76 | ) |
@@ -90,14 +89,14 @@ impl CrateImplBlocks { | |||
90 | self.impls_by_trait | 89 | self.impls_by_trait |
91 | .entry(tr.trait_) | 90 | .entry(tr.trait_) |
92 | .or_insert_with(Vec::new) | 91 | .or_insert_with(Vec::new) |
93 | .push((module.module_id, impl_id)); | 92 | .push((module.id.module_id, impl_id)); |
94 | } | 93 | } |
95 | } else { | 94 | } else { |
96 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { | 95 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { |
97 | self.impls | 96 | self.impls |
98 | .entry(target_ty_fp) | 97 | .entry(target_ty_fp) |
99 | .or_insert_with(Vec::new) | 98 | .or_insert_with(Vec::new) |
100 | .push((module.module_id, impl_id)); | 99 | .push((module.id.module_id, impl_id)); |
101 | } | 100 | } |
102 | } | 101 | } |
103 | } | 102 | } |