aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/coerce.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/infer/coerce.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs
index d66a21932..719a0f395 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/ra_hir_ty/src/infer/coerce.rs
@@ -4,16 +4,11 @@
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::{ 7use hir_def::{lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutability, AdtId};
8 lang_item::LangItemTarget,
9 resolver::{HasResolver, Resolver},
10 type_ref::Mutability,
11 AdtId,
12};
13use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
14use test_utils::tested_by; 9use test_utils::tested_by;
15 10
16use crate::{autoderef, db::HirDatabase, Substs, TraitRef, Ty, TypeCtor, TypeWalk}; 11use crate::{autoderef, db::HirDatabase, ImplTy, Substs, Ty, TypeCtor, TypeWalk};
17 12
18use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue}; 13use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue};
19 14
@@ -59,17 +54,12 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
59 impls 54 impls
60 .iter() 55 .iter()
61 .filter_map(|&impl_id| { 56 .filter_map(|&impl_id| {
62 let impl_data = db.impl_data(impl_id); 57 let trait_ref = match db.impl_ty(impl_id) {
63 let resolver = impl_id.resolver(db); 58 ImplTy::TraitRef(it) => it,
64 let target_ty = Ty::from_hir(db, &resolver, &impl_data.target_type); 59 ImplTy::Inherent(_) => return None,
60 };
65 61
66 // `CoerseUnsized` has one generic parameter for the target type. 62 // `CoerseUnsized` has one generic parameter for the target type.
67 let trait_ref = TraitRef::from_hir(
68 db,
69 &resolver,
70 impl_data.target_trait.as_ref()?,
71 Some(target_ty),
72 )?;
73 let cur_from_ty = trait_ref.substs.0.get(0)?; 63 let cur_from_ty = trait_ref.substs.0.get(0)?;
74 let cur_to_ty = trait_ref.substs.0.get(1)?; 64 let cur_to_ty = trait_ref.substs.0.get(1)?;
75 65