aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-11-30 11:39:21 +0000
committerFlorian Diebold <[email protected]>2019-11-30 11:57:32 +0000
commit3ca40f7c08718a44c6d08d2cbe060244340e7157 (patch)
treeac206c8e3303a151b0ef06a8de2c6c68acfd2fdd
parentcf6809645e2327e20edd30eb535d4f06fa116b5c (diff)
Add cycle recovery for generic predicates
-rw-r--r--crates/ra_hir_ty/src/db.rs1
-rw-r--r--crates/ra_hir_ty/src/lower.rs9
-rw-r--r--crates/ra_hir_ty/src/tests.rs8
3 files changed, 10 insertions, 8 deletions
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index 6ecc0b096..8e461e359 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -41,6 +41,7 @@ pub trait HirDatabase: DefDatabase {
41 fn callable_item_signature(&self, def: CallableDef) -> FnSig; 41 fn callable_item_signature(&self, def: CallableDef) -> FnSig;
42 42
43 #[salsa::invoke(crate::lower::generic_predicates_for_param_query)] 43 #[salsa::invoke(crate::lower::generic_predicates_for_param_query)]
44 #[salsa::cycle(crate::lower::generic_predicates_for_param_recover)]
44 fn generic_predicates_for_param( 45 fn generic_predicates_for_param(
45 &self, 46 &self,
46 def: GenericDefId, 47 def: GenericDefId,
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index a646406f1..c6ee75c7a 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -532,6 +532,15 @@ pub(crate) fn generic_predicates_for_param_query(
532 .collect() 532 .collect()
533} 533}
534 534
535pub(crate) fn generic_predicates_for_param_recover(
536 _db: &impl HirDatabase,
537 _cycle: &[String],
538 _def: &GenericDefId,
539 _param_idx: &u32,
540) -> Arc<[GenericPredicate]> {
541 Arc::new([])
542}
543
535impl TraitEnvironment { 544impl TraitEnvironment {
536 pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> { 545 pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> {
537 let predicates = resolver 546 let predicates = resolver
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index b72f0f279..552eb8f75 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -4718,10 +4718,6 @@ fn test() {
4718} 4718}
4719 4719
4720#[test] 4720#[test]
4721// FIXME this is currently a Salsa panic; it would be nicer if it just returned
4722// in Unknown, and we should be able to do that once Salsa allows us to handle
4723// the cycle. But at least it doesn't overflow for now.
4724#[should_panic]
4725fn unselected_projection_in_trait_env_cycle_1() { 4721fn unselected_projection_in_trait_env_cycle_1() {
4726 let t = type_at( 4722 let t = type_at(
4727 r#" 4723 r#"
@@ -4742,10 +4738,6 @@ fn test<T: Trait>() where T: Trait2<T::Item> {
4742} 4738}
4743 4739
4744#[test] 4740#[test]
4745// FIXME this is currently a Salsa panic; it would be nicer if it just returned
4746// in Unknown, and we should be able to do that once Salsa allows us to handle
4747// the cycle. But at least it doesn't overflow for now.
4748#[should_panic]
4749fn unselected_projection_in_trait_env_cycle_2() { 4741fn unselected_projection_in_trait_env_cycle_2() {
4750 let t = type_at( 4742 let t = type_at(
4751 r#" 4743 r#"