]> git.lizzy.rs Git - rust.git/commitdiff
Add cycle recovery for generic predicates
authorFlorian Diebold <flodiebold@gmail.com>
Sat, 30 Nov 2019 11:39:21 +0000 (12:39 +0100)
committerFlorian Diebold <flodiebold@gmail.com>
Sat, 30 Nov 2019 11:57:32 +0000 (12:57 +0100)
crates/ra_hir_ty/src/db.rs
crates/ra_hir_ty/src/lower.rs
crates/ra_hir_ty/src/tests.rs

index 6ecc0b09664c940365732f6241f2dfb5b4965bc9..8e461e35922af5de7113d178f5b9a6bc130d2093 100644 (file)
@@ -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,
index a646406f18e61c71268936ccfd15a3dd2868f0f8..c6ee75c7ae0993cf4830423f79a6c99e678226ca 100644 (file)
@@ -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<TraitEnvironment> {
         let predicates = resolver
index b72f0f2797034b652c22fbb458178e6023560684..552eb8f75a4f93d922f01c90b7815a5caf3ad568 100644 (file)
@@ -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<T: Trait>() where T: Trait2<T::Item> {
 }
 
 #[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#"