aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/method_resolution.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-06-29 18:14:52 +0100
committerFlorian Diebold <[email protected]>2019-07-08 20:20:17 +0100
commitb1b12072eddaf989fb08ed7a2e39ec2dbbb83dde (patch)
tree63bb052a39df80dcd0771a18a7a475df3e6a5fe1 /crates/ra_hir/src/ty/method_resolution.rs
parent638100dc8bea69cc4093d15f1641ed39a8d27a43 (diff)
Start handling environment in trait resolution
I.e. if we are inside a function with some where clauses, we assume these where clauses hold.
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 770e1964e..40f5eabf0 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -7,7 +7,7 @@ use std::sync::Arc;
7use arrayvec::ArrayVec; 7use arrayvec::ArrayVec;
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9 9
10use super::{autoderef, Canonical, Environment, InEnvironment, TraitRef}; 10use super::{autoderef, lower, Canonical, Environment, InEnvironment, TraitRef};
11use crate::{ 11use crate::{
12 generics::HasGenericParams, 12 generics::HasGenericParams,
13 impl_block::{ImplBlock, ImplId, ImplItem}, 13 impl_block::{ImplBlock, ImplId, ImplItem},
@@ -198,6 +198,8 @@ fn iterate_trait_method_candidates<T>(
198 mut callback: impl FnMut(&Ty, Function) -> Option<T>, 198 mut callback: impl FnMut(&Ty, Function) -> Option<T>,
199) -> Option<T> { 199) -> Option<T> {
200 let krate = resolver.krate()?; 200 let krate = resolver.krate()?;
201 // FIXME: maybe put the trait_env behind a query (need to figure out good input parameters for that)
202 let env = lower::trait_env(db, resolver);
201 'traits: for t in resolver.traits_in_scope(db) { 203 'traits: for t in resolver.traits_in_scope(db) {
202 let data = t.trait_data(db); 204 let data = t.trait_data(db);
203 // we'll be lazy about checking whether the type implements the 205 // we'll be lazy about checking whether the type implements the
@@ -209,8 +211,7 @@ fn iterate_trait_method_candidates<T>(
209 let data = m.data(db); 211 let data = m.data(db);
210 if name.map_or(true, |name| data.name() == name) && data.has_self_param() { 212 if name.map_or(true, |name| data.name() == name) && data.has_self_param() {
211 if !known_implemented { 213 if !known_implemented {
212 let env = Arc::new(super::Environment); // FIXME add environment 214 let trait_ref = canonical_trait_ref(db, env.clone(), t, ty.clone());
213 let trait_ref = canonical_trait_ref(db, env, t, ty.clone());
214 if db.implements(krate, trait_ref).is_none() { 215 if db.implements(krate, trait_ref).is_none() {
215 continue 'traits; 216 continue 'traits;
216 } 217 }