diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index e2351ca98..dc78e83cd 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -850,6 +850,59 @@ fn test<T: ApplyL>(t: T) { | |||
850 | } | 850 | } |
851 | 851 | ||
852 | #[test] | 852 | #[test] |
853 | fn argument_impl_trait() { | ||
854 | assert_snapshot!( | ||
855 | infer_with_mismatches(r#" | ||
856 | trait Trait<T> { | ||
857 | fn foo(&self) -> T; | ||
858 | fn foo2(&self) -> i64; | ||
859 | } | ||
860 | fn bar(impl Trait<u64>) {} | ||
861 | struct S<T>(T); | ||
862 | impl<T> Trait<T> for S<T> {} | ||
863 | |||
864 | fn test(x: impl Trait<u64>, y: &impl Trait<u64>) { | ||
865 | x; | ||
866 | y; | ||
867 | let z = S(1); | ||
868 | bar(z); | ||
869 | x.foo(); | ||
870 | y.foo(); | ||
871 | z.foo(); | ||
872 | x.foo2(); | ||
873 | y.foo2(); | ||
874 | z.foo2(); | ||
875 | } | ||
876 | "#, true), | ||
877 | @r###" | ||
878 | [30; 34) 'self': &Self | ||
879 | [55; 59) 'self': &Self | ||
880 | [99; 101) '{}': () | ||
881 | [111; 112) 'x': impl Trait<u64> | ||
882 | [131; 132) 'y': &impl Trait<u64> | ||
883 | [152; 269) '{ ...2(); }': () | ||
884 | [158; 159) 'x': impl Trait<u64> | ||
885 | [165; 166) 'y': &impl Trait<u64> | ||
886 | [176; 177) 'z': impl Trait<u64> | ||
887 | [180; 183) 'bar': fn bar() -> impl Trait<u64> | ||
888 | [180; 185) 'bar()': impl Trait<u64> | ||
889 | [191; 192) 'x': impl Trait<u64> | ||
890 | [191; 198) 'x.foo()': u64 | ||
891 | [204; 205) 'y': &impl Trait<u64> | ||
892 | [204; 211) 'y.foo()': u64 | ||
893 | [217; 218) 'z': impl Trait<u64> | ||
894 | [217; 224) 'z.foo()': u64 | ||
895 | [230; 231) 'x': impl Trait<u64> | ||
896 | [230; 238) 'x.foo2()': i64 | ||
897 | [244; 245) 'y': &impl Trait<u64> | ||
898 | [244; 252) 'y.foo2()': i64 | ||
899 | [258; 259) 'z': impl Trait<u64> | ||
900 | [258; 266) 'z.foo2()': i64 | ||
901 | "### | ||
902 | ); | ||
903 | } | ||
904 | |||
905 | #[test] | ||
853 | #[ignore] | 906 | #[ignore] |
854 | fn impl_trait() { | 907 | fn impl_trait() { |
855 | assert_snapshot!( | 908 | assert_snapshot!( |