diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-21 12:50:12 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-21 12:50:12 +0000 |
commit | 1f61915bde4c5d8d4fe2e9b8dfa9445008730b79 (patch) | |
tree | a6fd0b6ad8b6c87d28e6e1b36bb9b2fbae2c1b09 /crates/ra_hir/src/ty/method_resolution.rs | |
parent | 612a72fc4ea4376920f2a7da7b3c334227c1716c (diff) | |
parent | c37d1c5b381365ce2d07dfe4b871e43995ccea2d (diff) |
Merge #2337
2337: Move resolver to hir_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index f377fca48..64adb814d 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -5,11 +5,11 @@ | |||
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use hir_def::resolver::Resolver; | ||
8 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
9 | 10 | ||
10 | use crate::{ | 11 | use crate::{ |
11 | db::HirDatabase, | 12 | db::HirDatabase, |
12 | resolve::Resolver, | ||
13 | ty::primitive::{FloatBitness, Uncertain}, | 13 | ty::primitive::{FloatBitness, Uncertain}, |
14 | ty::{Ty, TypeCtor}, | 14 | ty::{Ty, TypeCtor}, |
15 | AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait, | 15 | AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait, |
@@ -172,9 +172,14 @@ pub(crate) fn iterate_method_candidates<T>( | |||
172 | // rustc does an autoderef and then autoref again). | 172 | // rustc does an autoderef and then autoref again). |
173 | 173 | ||
174 | for derefed_ty in autoderef::autoderef(db, resolver, ty.clone()) { | 174 | for derefed_ty in autoderef::autoderef(db, resolver, ty.clone()) { |
175 | if let Some(result) = | 175 | if let Some(result) = iterate_inherent_methods( |
176 | iterate_inherent_methods(&derefed_ty, db, name, mode, krate, &mut callback) | 176 | &derefed_ty, |
177 | { | 177 | db, |
178 | name, | ||
179 | mode, | ||
180 | krate.into(), | ||
181 | &mut callback, | ||
182 | ) { | ||
178 | return Some(result); | 183 | return Some(result); |
179 | } | 184 | } |
180 | if let Some(result) = iterate_trait_method_candidates( | 185 | if let Some(result) = iterate_trait_method_candidates( |
@@ -192,7 +197,7 @@ pub(crate) fn iterate_method_candidates<T>( | |||
192 | LookupMode::Path => { | 197 | LookupMode::Path => { |
193 | // No autoderef for path lookups | 198 | // No autoderef for path lookups |
194 | if let Some(result) = | 199 | if let Some(result) = |
195 | iterate_inherent_methods(&ty, db, name, mode, krate, &mut callback) | 200 | iterate_inherent_methods(&ty, db, name, mode, krate.into(), &mut callback) |
196 | { | 201 | { |
197 | return Some(result); | 202 | return Some(result); |
198 | } | 203 | } |
@@ -224,7 +229,9 @@ fn iterate_trait_method_candidates<T>( | |||
224 | .trait_predicates_for_self_ty(&ty.value) | 229 | .trait_predicates_for_self_ty(&ty.value) |
225 | .map(|tr| tr.trait_) | 230 | .map(|tr| tr.trait_) |
226 | .flat_map(|t| t.all_super_traits(db)); | 231 | .flat_map(|t| t.all_super_traits(db)); |
227 | let traits = inherent_trait.chain(traits_from_env).chain(resolver.traits_in_scope(db)); | 232 | let traits = inherent_trait |
233 | .chain(traits_from_env) | ||
234 | .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from)); | ||
228 | 'traits: for t in traits { | 235 | 'traits: for t in traits { |
229 | let data = t.trait_data(db); | 236 | let data = t.trait_data(db); |
230 | 237 | ||
@@ -238,7 +245,7 @@ fn iterate_trait_method_candidates<T>( | |||
238 | } | 245 | } |
239 | if !known_implemented { | 246 | if !known_implemented { |
240 | let goal = generic_implements_goal(db, env.clone(), t, ty.clone()); | 247 | let goal = generic_implements_goal(db, env.clone(), t, ty.clone()); |
241 | if db.trait_solve(krate, goal).is_none() { | 248 | if db.trait_solve(krate.into(), goal).is_none() { |
242 | continue 'traits; | 249 | continue 'traits; |
243 | } | 250 | } |
244 | } | 251 | } |