diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 4ba87e667..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 | ||
@@ -4676,10 +4678,48 @@ fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> { | |||
4676 | } | 4678 | } |
4677 | 4679 | ||
4678 | #[test] | 4680 | #[test] |
4679 | // FIXME this is currently a Salsa panic; it would be nicer if it just returned | 4681 | fn trait_impl_self_ty() { |
4680 | // in Unknown, and we should be able to do that once Salsa allows us to handle | 4682 | let t = type_at( |
4681 | // the cycle. But at least it doesn't overflow for now. | 4683 | r#" |
4682 | #[should_panic] | 4684 | //- /main.rs |
4685 | trait Trait<T> { | ||
4686 | fn foo(&self); | ||
4687 | } | ||
4688 | |||
4689 | struct S; | ||
4690 | |||
4691 | impl Trait<Self> for S {} | ||
4692 | |||
4693 | fn test() { | ||
4694 | S.foo()<|>; | ||
4695 | } | ||
4696 | "#, | ||
4697 | ); | ||
4698 | assert_eq!(t, "()"); | ||
4699 | } | ||
4700 | |||
4701 | #[test] | ||
4702 | fn trait_impl_self_ty_cycle() { | ||
4703 | let t = type_at( | ||
4704 | r#" | ||
4705 | //- /main.rs | ||
4706 | trait Trait { | ||
4707 | fn foo(&self); | ||
4708 | } | ||
4709 | |||
4710 | struct S<T>; | ||
4711 | |||
4712 | impl Trait for S<Self> {} | ||
4713 | |||
4714 | fn test() { | ||
4715 | S.foo()<|>; | ||
4716 | } | ||
4717 | "#, | ||
4718 | ); | ||
4719 | assert_eq!(t, "{unknown}"); | ||
4720 | } | ||
4721 | |||
4722 | #[test] | ||
4683 | fn unselected_projection_in_trait_env_cycle_1() { | 4723 | fn unselected_projection_in_trait_env_cycle_1() { |
4684 | let t = type_at( | 4724 | let t = type_at( |
4685 | r#" | 4725 | r#" |
@@ -4700,10 +4740,6 @@ fn test<T: Trait>() where T: Trait2<T::Item> { | |||
4700 | } | 4740 | } |
4701 | 4741 | ||
4702 | #[test] | 4742 | #[test] |
4703 | // FIXME this is currently a Salsa panic; it would be nicer if it just returned | ||
4704 | // in Unknown, and we should be able to do that once Salsa allows us to handle | ||
4705 | // the cycle. But at least it doesn't overflow for now. | ||
4706 | #[should_panic] | ||
4707 | fn unselected_projection_in_trait_env_cycle_2() { | 4743 | fn unselected_projection_in_trait_env_cycle_2() { |
4708 | let t = type_at( | 4744 | let t = type_at( |
4709 | r#" | 4745 | r#" |