diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-30 14:23:18 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-30 14:23:18 +0000 |
commit | 9712889ee4c6cffa37c2ace5da9b00bf29adab56 (patch) | |
tree | 0471718f620bfdcb207387f6ae58bdfa5ca47e4e /crates/ra_hir_ty/src/traits | |
parent | 7cecd0f331419439417f98d92b839c9aaa06ed86 (diff) | |
parent | 1c622e9fed97de7711da7b5bffec0fa4b19d7500 (diff) |
Merge #2453
2453: Handle various cycles r=matklad a=flodiebold
- handle `impl Trait<Self> for SomeType`, which is allowed. This necessitated splitting the `impl_ty` query, but I think the result actually makes a lot of code nicer. This should fix #2446.
- add recovery for `impl Trait for SomeType<Self>`
- add recovery for `type Type = Foo<Type>`
- add recovery for cycles in generic param env
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 15 |
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 | ||
21 | use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; | 21 | use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; |
22 | use crate::{ | 22 | use 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_) |