From 3ca40f7c08718a44c6d08d2cbe060244340e7157 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 30 Nov 2019 12:39:21 +0100 Subject: Add cycle recovery for generic predicates --- crates/ra_hir_ty/src/db.rs | 1 + crates/ra_hir_ty/src/lower.rs | 9 +++++++++ crates/ra_hir_ty/src/tests.rs | 8 -------- 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 { fn callable_item_signature(&self, def: CallableDef) -> FnSig; #[salsa::invoke(crate::lower::generic_predicates_for_param_query)] + #[salsa::cycle(crate::lower::generic_predicates_for_param_recover)] fn generic_predicates_for_param( &self, 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( .collect() } +pub(crate) fn generic_predicates_for_param_recover( + _db: &impl HirDatabase, + _cycle: &[String], + _def: &GenericDefId, + _param_idx: &u32, +) -> Arc<[GenericPredicate]> { + Arc::new([]) +} + impl TraitEnvironment { pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc { 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() { } #[test] -// FIXME this is currently a Salsa panic; it would be nicer if it just returned -// in Unknown, and we should be able to do that once Salsa allows us to handle -// the cycle. But at least it doesn't overflow for now. -#[should_panic] fn unselected_projection_in_trait_env_cycle_1() { let t = type_at( r#" @@ -4742,10 +4738,6 @@ fn test() where T: Trait2 { } #[test] -// FIXME this is currently a Salsa panic; it would be nicer if it just returned -// in Unknown, and we should be able to do that once Salsa allows us to handle -// the cycle. But at least it doesn't overflow for now. -#[should_panic] fn unselected_projection_in_trait_env_cycle_2() { let t = type_at( r#" -- cgit v1.2.3