aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/infer')
-rw-r--r--crates/ra_hir/src/ty/infer/coerce.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/ra_hir/src/ty/infer/coerce.rs b/crates/ra_hir/src/ty/infer/coerce.rs
index 5ed4470af..cf45ede7c 100644
--- a/crates/ra_hir/src/ty/infer/coerce.rs
+++ b/crates/ra_hir/src/ty/infer/coerce.rs
@@ -4,13 +4,17 @@
4//! 4//!
5//! See: https://doc.rust-lang.org/nomicon/coercions.html 5//! See: https://doc.rust-lang.org/nomicon/coercions.html
6 6
7use hir_def::{lang_item::LangItemTarget, resolver::Resolver, AdtId}; 7use hir_def::{
8 lang_item::LangItemTarget,
9 resolver::{HasResolver, Resolver},
10 AdtId,
11};
8use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
9use test_utils::tested_by; 13use test_utils::tested_by;
10 14
11use crate::{ 15use crate::{
12 db::HirDatabase, 16 db::HirDatabase,
13 ty::{autoderef, Substs, Ty, TypeCtor, TypeWalk}, 17 ty::{autoderef, Substs, TraitRef, Ty, TypeCtor, TypeWalk},
14 Mutability, 18 Mutability,
15}; 19};
16 20
@@ -57,9 +61,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
57 61
58 impls 62 impls
59 .iter() 63 .iter()
60 .filter_map(|impl_block| { 64 .filter_map(|&impl_id| {
65 let impl_data = db.impl_data(impl_id);
66 let resolver = impl_id.resolver(db);
67 let target_ty = Ty::from_hir(db, &resolver, &impl_data.target_type);
68
61 // `CoerseUnsized` has one generic parameter for the target type. 69 // `CoerseUnsized` has one generic parameter for the target type.
62 let trait_ref = impl_block.target_trait_ref(db)?; 70 let trait_ref = TraitRef::from_hir(
71 db,
72 &resolver,
73 impl_data.target_trait.as_ref()?,
74 Some(target_ty),
75 )?;
63 let cur_from_ty = trait_ref.substs.0.get(0)?; 76 let cur_from_ty = trait_ref.substs.0.get(0)?;
64 let cur_to_ty = trait_ref.substs.0.get(1)?; 77 let cur_to_ty = trait_ref.substs.0.get(1)?;
65 78