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