aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/method_resolution.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-26 15:00:36 +0000
committerAleksey Kladov <[email protected]>2019-11-26 15:01:34 +0000
commit72d8e7e69abca9f27fb3ea386a6879324741e152 (patch)
tree55d2afdba12adaff0e7c329b6d0dfc79efb6db73 /crates/ra_hir/src/ty/method_resolution.rs
parent6560e4ff2eae4e54384896d6ae100f1d2df20518 (diff)
Use TraitId in TraitRef
Diffstat (limited to 'crates/ra_hir/src/ty/method_resolution.rs')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index 9988570e8..f1bc638ee 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -68,7 +68,7 @@ impl CrateImplBlocks {
68 if let Some(tr) = 68 if let Some(tr) =
69 TraitRef::from_hir(db, &resolver, &trait_ref, Some(target_ty)) 69 TraitRef::from_hir(db, &resolver, &trait_ref, Some(target_ty))
70 { 70 {
71 res.impls_by_trait.entry(tr.trait_.id).or_default().push(impl_id); 71 res.impls_by_trait.entry(tr.trait_).or_default().push(impl_id);
72 } 72 }
73 } 73 }
74 None => { 74 None => {
@@ -249,13 +249,11 @@ fn iterate_trait_method_candidates<T>(
249 let traits_from_env = env 249 let traits_from_env = env
250 .trait_predicates_for_self_ty(&ty.value) 250 .trait_predicates_for_self_ty(&ty.value)
251 .map(|tr| tr.trait_) 251 .map(|tr| tr.trait_)
252 .flat_map(|t| all_super_traits(db, t.id)) 252 .flat_map(|t| all_super_traits(db, t));
253 .map(Trait::from); 253 let traits =
254 let traits = inherent_trait 254 inherent_trait.chain(traits_from_env).chain(resolver.traits_in_scope(db).into_iter());
255 .chain(traits_from_env)
256 .chain(resolver.traits_in_scope(db).into_iter().map(Trait::from));
257 'traits: for t in traits { 255 'traits: for t in traits {
258 let data = db.trait_data(t.id); 256 let data = db.trait_data(t);
259 257
260 // we'll be lazy about checking whether the type implements the 258 // we'll be lazy about checking whether the type implements the
261 // trait, but if we find out it doesn't, we'll skip the rest of the 259 // trait, but if we find out it doesn't, we'll skip the rest of the
@@ -330,7 +328,7 @@ pub(crate) fn implements_trait(
330 db: &impl HirDatabase, 328 db: &impl HirDatabase,
331 resolver: &Resolver, 329 resolver: &Resolver,
332 krate: Crate, 330 krate: Crate,
333 trait_: Trait, 331 trait_: TraitId,
334) -> bool { 332) -> bool {
335 if ty.value.inherent_trait() == Some(trait_) { 333 if ty.value.inherent_trait() == Some(trait_) {
336 // FIXME this is a bit of a hack, since Chalk should say the same thing 334 // FIXME this is a bit of a hack, since Chalk should say the same thing
@@ -373,11 +371,11 @@ impl Ty {
373fn generic_implements_goal( 371fn generic_implements_goal(
374 db: &impl HirDatabase, 372 db: &impl HirDatabase,
375 env: Arc<TraitEnvironment>, 373 env: Arc<TraitEnvironment>,
376 trait_: Trait, 374 trait_: TraitId,
377 self_ty: Canonical<Ty>, 375 self_ty: Canonical<Ty>,
378) -> Canonical<InEnvironment<super::Obligation>> { 376) -> Canonical<InEnvironment<super::Obligation>> {
379 let num_vars = self_ty.num_vars; 377 let num_vars = self_ty.num_vars;
380 let substs = super::Substs::build_for_def(db, trait_.id) 378 let substs = super::Substs::build_for_def(db, trait_)
381 .push(self_ty.value) 379 .push(self_ty.value)
382 .fill_with_bound_vars(num_vars as u32) 380 .fill_with_bound_vars(num_vars as u32)
383 .build(); 381 .build();