aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-11-30 11:35:37 +0000
committerFlorian Diebold <[email protected]>2019-11-30 11:57:32 +0000
commitcf6809645e2327e20edd30eb535d4f06fa116b5c (patch)
treed39c0827865f5e82d82da94bc595580ad811502b /crates/ra_hir_ty/src/traits
parent7cecd0f331419439417f98d92b839c9aaa06ed86 (diff)
Handle cycles in impl types better
- impl Trait<Self> for S is allowed - impl Trait for S<Self> is an invalid cycle, but we can add cycle recovery for it in Salsa now
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 35de37e6b..104346ada 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -20,8 +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, display::HirDisplay, ApplicationTy, GenericPredicate, ImplTy, ProjectionTy, 23 db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ProjectionTy, Substs,
24 Substs, TraitRef, Ty, TypeCtor, TypeWalk, 24 TraitRef, Ty, TypeCtor, TypeWalk,
25}; 25};
26 26
27/// This represents a trait whose name we could not resolve. 27/// This represents a trait whose name we could not resolve.
@@ -630,10 +630,7 @@ fn impl_block_datum(
630 chalk_id: chalk_ir::ImplId, 630 chalk_id: chalk_ir::ImplId,
631 impl_id: ImplId, 631 impl_id: ImplId,
632) -> Option<Arc<ImplDatum<ChalkIr>>> { 632) -> Option<Arc<ImplDatum<ChalkIr>>> {
633 let trait_ref = match db.impl_ty(impl_id) { 633 let trait_ref = db.impl_trait(impl_id)?;
634 ImplTy::TraitRef(it) => it,
635 ImplTy::Inherent(_) => return None,
636 };
637 let impl_data = db.impl_data(impl_id); 634 let impl_data = db.impl_data(impl_id);
638 635
639 let generic_params = db.generic_params(impl_id.into()); 636 let generic_params = db.generic_params(impl_id.into());
@@ -787,11 +784,7 @@ fn type_alias_associated_ty_value(
787 _ => panic!("assoc ty value should be in impl"), 784 _ => panic!("assoc ty value should be in impl"),
788 }; 785 };
789 786
790 let trait_ref = match db.impl_ty(impl_id) { 787 let trait_ref = db.impl_trait(impl_id).expect("assoc ty value should not exist"); // we don't return any assoc ty values if the impl'd trait can't be resolved
791 ImplTy::TraitRef(it) => it,
792 // we don't return any assoc ty values if the impl'd trait can't be resolved
793 ImplTy::Inherent(_) => panic!("assoc ty value should not exist"),
794 };
795 788
796 let assoc_ty = db 789 let assoc_ty = db
797 .trait_data(trait_ref.trait_) 790 .trait_data(trait_ref.trait_)