diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 33 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 30 |
2 files changed, 59 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 6b5267232..5ddecbdc6 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -622,14 +622,14 @@ fn main() { | |||
622 | fn infer_derive_clone_simple() { | 622 | fn infer_derive_clone_simple() { |
623 | let (db, pos) = TestDB::with_position( | 623 | let (db, pos) = TestDB::with_position( |
624 | r#" | 624 | r#" |
625 | //- /main.rs crate:main deps:std | 625 | //- /main.rs crate:main deps:core |
626 | #[derive(Clone)] | 626 | #[derive(Clone)] |
627 | struct S; | 627 | struct S; |
628 | fn test() { | 628 | fn test() { |
629 | S.clone()<|>; | 629 | S.clone()<|>; |
630 | } | 630 | } |
631 | 631 | ||
632 | //- /lib.rs crate:std | 632 | //- /lib.rs crate:core |
633 | #[prelude_import] | 633 | #[prelude_import] |
634 | use clone::*; | 634 | use clone::*; |
635 | mod clone { | 635 | mod clone { |
@@ -643,10 +643,35 @@ mod clone { | |||
643 | } | 643 | } |
644 | 644 | ||
645 | #[test] | 645 | #[test] |
646 | fn infer_derive_clone_in_core() { | ||
647 | let (db, pos) = TestDB::with_position( | ||
648 | r#" | ||
649 | //- /lib.rs crate:core | ||
650 | #[prelude_import] | ||
651 | use clone::*; | ||
652 | mod clone { | ||
653 | trait Clone { | ||
654 | fn clone(&self) -> Self; | ||
655 | } | ||
656 | } | ||
657 | #[derive(Clone)] | ||
658 | pub struct S; | ||
659 | |||
660 | //- /main.rs crate:main deps:core | ||
661 | use core::S; | ||
662 | fn test() { | ||
663 | S.clone()<|>; | ||
664 | } | ||
665 | "#, | ||
666 | ); | ||
667 | assert_eq!("S", type_at_pos(&db, pos)); | ||
668 | } | ||
669 | |||
670 | #[test] | ||
646 | fn infer_derive_clone_with_params() { | 671 | fn infer_derive_clone_with_params() { |
647 | let (db, pos) = TestDB::with_position( | 672 | let (db, pos) = TestDB::with_position( |
648 | r#" | 673 | r#" |
649 | //- /main.rs crate:main deps:std | 674 | //- /main.rs crate:main deps:core |
650 | #[derive(Clone)] | 675 | #[derive(Clone)] |
651 | struct S; | 676 | struct S; |
652 | #[derive(Clone)] | 677 | #[derive(Clone)] |
@@ -656,7 +681,7 @@ fn test() { | |||
656 | (Wrapper(S).clone(), Wrapper(NonClone).clone())<|>; | 681 | (Wrapper(S).clone(), Wrapper(NonClone).clone())<|>; |
657 | } | 682 | } |
658 | 683 | ||
659 | //- /lib.rs crate:std | 684 | //- /lib.rs crate:core |
660 | #[prelude_import] | 685 | #[prelude_import] |
661 | use clone::*; | 686 | use clone::*; |
662 | mod clone { | 687 | mod clone { |
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index f51cdd496..e555c879a 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -1898,6 +1898,36 @@ fn test() { | |||
1898 | } | 1898 | } |
1899 | 1899 | ||
1900 | #[test] | 1900 | #[test] |
1901 | fn unselected_projection_chalk_fold() { | ||
1902 | let t = type_at( | ||
1903 | r#" | ||
1904 | //- /main.rs | ||
1905 | trait Interner {} | ||
1906 | trait Fold<I: Interner, TI = I> { | ||
1907 | type Result; | ||
1908 | } | ||
1909 | |||
1910 | struct Ty<I: Interner> {} | ||
1911 | impl<I: Interner, TI: Interner> Fold<I, TI> for Ty<I> { | ||
1912 | type Result = Ty<TI>; | ||
1913 | } | ||
1914 | |||
1915 | fn fold<I: Interner, T>(interner: &I, t: T) -> T::Result | ||
1916 | where | ||
1917 | T: Fold<I, I>, | ||
1918 | { | ||
1919 | loop {} | ||
1920 | } | ||
1921 | |||
1922 | fn foo<I: Interner>(interner: &I, t: Ty<I>) { | ||
1923 | fold(interner, t)<|>; | ||
1924 | } | ||
1925 | "#, | ||
1926 | ); | ||
1927 | assert_eq!(t, "Ty<I>"); | ||
1928 | } | ||
1929 | |||
1930 | #[test] | ||
1901 | fn trait_impl_self_ty() { | 1931 | fn trait_impl_self_ty() { |
1902 | let t = type_at( | 1932 | let t = type_at( |
1903 | r#" | 1933 | r#" |