aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits/chalk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk.rs')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 810e8c21a..35de37e6b 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -11,8 +11,8 @@ use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum
11use ra_db::CrateId; 11use ra_db::CrateId;
12 12
13use hir_def::{ 13use hir_def::{
14 expr::Expr, lang_item::LangItemTarget, resolver::HasResolver, AssocItemId, AstItemDef, 14 expr::Expr, lang_item::LangItemTarget, AssocItemId, AstItemDef, ContainerId, GenericDefId,
15 ContainerId, GenericDefId, ImplId, Lookup, TraitId, TypeAliasId, 15 ImplId, Lookup, TraitId, TypeAliasId,
16}; 16};
17use hir_expand::name; 17use hir_expand::name;
18 18
@@ -20,9 +20,8 @@ use ra_db::salsa::{InternId, InternKey};
20 20
21use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; 21use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation};
22use crate::{ 22use crate::{
23 db::HirDatabase, 23 db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ImplTy, ProjectionTy,
24 display::HirDisplay, 24 Substs, TraitRef, Ty, TypeCtor, TypeWalk,
25 {ApplicationTy, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk},
26}; 25};
27 26
28/// This represents a trait whose name we could not resolve. 27/// This represents a trait whose name we could not resolve.
@@ -631,13 +630,11 @@ fn impl_block_datum(
631 chalk_id: chalk_ir::ImplId, 630 chalk_id: chalk_ir::ImplId,
632 impl_id: ImplId, 631 impl_id: ImplId,
633) -> Option<Arc<ImplDatum<ChalkIr>>> { 632) -> Option<Arc<ImplDatum<ChalkIr>>> {
633 let trait_ref = match db.impl_ty(impl_id) {
634 ImplTy::TraitRef(it) => it,
635 ImplTy::Inherent(_) => return None,
636 };
634 let impl_data = db.impl_data(impl_id); 637 let impl_data = db.impl_data(impl_id);
635 let resolver = impl_id.resolver(db);
636 let target_ty = Ty::from_hir(db, &resolver, &impl_data.target_type);
637
638 // `CoerseUnsized` has one generic parameter for the target type.
639 let trait_ref =
640 TraitRef::from_hir(db, &resolver, impl_data.target_trait.as_ref()?, Some(target_ty))?;
641 638
642 let generic_params = db.generic_params(impl_id.into()); 639 let generic_params = db.generic_params(impl_id.into());
643 let bound_vars = Substs::bound_vars(&generic_params); 640 let bound_vars = Substs::bound_vars(&generic_params);
@@ -790,17 +787,14 @@ fn type_alias_associated_ty_value(
790 _ => panic!("assoc ty value should be in impl"), 787 _ => panic!("assoc ty value should be in impl"),
791 }; 788 };
792 789
793 let impl_data = db.impl_data(impl_id); 790 let trait_ref = match db.impl_ty(impl_id) {
794 let resolver = impl_id.resolver(db); 791 ImplTy::TraitRef(it) => it,
795 let target_ty = Ty::from_hir(db, &resolver, &impl_data.target_type); 792 // we don't return any assoc ty values if the impl'd trait can't be resolved
796 let target_trait = impl_data 793 ImplTy::Inherent(_) => panic!("assoc ty value should not exist"),
797 .target_trait 794 };
798 .as_ref()
799 .and_then(|trait_ref| TraitRef::from_hir(db, &resolver, &trait_ref, Some(target_ty)))
800 .expect("assoc ty value should not exist"); // we don't return any assoc ty values if the impl'd trait can't be resolved
801 795
802 let assoc_ty = db 796 let assoc_ty = db
803 .trait_data(target_trait.trait_) 797 .trait_data(trait_ref.trait_)
804 .associated_type_by_name(&type_alias_data.name) 798 .associated_type_by_name(&type_alias_data.name)
805 .expect("assoc ty value should not exist"); // validated when building the impl data as well 799 .expect("assoc ty value should not exist"); // validated when building the impl data as well
806 let generic_params = db.generic_params(impl_id.into()); 800 let generic_params = db.generic_params(impl_id.into());