diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/db.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 6 |
3 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 8e461e359..222a36a9f 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs | |||
@@ -22,6 +22,7 @@ pub trait HirDatabase: DefDatabase { | |||
22 | fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; | 22 | fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; |
23 | 23 | ||
24 | #[salsa::invoke(crate::lower::ty_query)] | 24 | #[salsa::invoke(crate::lower::ty_query)] |
25 | #[salsa::cycle(crate::lower::ty_recover)] | ||
25 | fn ty(&self, def: TyDefId) -> Ty; | 26 | fn ty(&self, def: TyDefId) -> Ty; |
26 | 27 | ||
27 | #[salsa::invoke(crate::lower::value_ty_query)] | 28 | #[salsa::invoke(crate::lower::value_ty_query)] |
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index c6ee75c7a..32569ac66 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -742,6 +742,11 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Ty { | |||
742 | TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), | 742 | TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), |
743 | } | 743 | } |
744 | } | 744 | } |
745 | |||
746 | pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Ty { | ||
747 | Ty::Unknown | ||
748 | } | ||
749 | |||
745 | pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { | 750 | pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { |
746 | match def { | 751 | match def { |
747 | ValueTyDefId::FunctionId(it) => type_for_fn(db, it), | 752 | ValueTyDefId::FunctionId(it) => type_for_fn(db, it), |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 552eb8f75..c856d6afd 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -2154,7 +2154,6 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) { | |||
2154 | } | 2154 | } |
2155 | 2155 | ||
2156 | #[test] | 2156 | #[test] |
2157 | #[should_panic] // we currently can't handle this | ||
2158 | fn recursive_type_alias() { | 2157 | fn recursive_type_alias() { |
2159 | assert_snapshot!( | 2158 | assert_snapshot!( |
2160 | infer(r#" | 2159 | infer(r#" |
@@ -2163,7 +2162,10 @@ type Foo = Foo; | |||
2163 | type Bar = A<Bar>; | 2162 | type Bar = A<Bar>; |
2164 | fn test(x: Foo) {} | 2163 | fn test(x: Foo) {} |
2165 | "#), | 2164 | "#), |
2166 | @"" | 2165 | @r###" |
2166 | [59; 60) 'x': {unknown} | ||
2167 | [67; 69) '{}': () | ||
2168 | "### | ||
2167 | ) | 2169 | ) |
2168 | } | 2170 | } |
2169 | 2171 | ||