diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index acae71c26..0f2172ddf 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -831,6 +831,60 @@ fn test(x: &i32) { | |||
831 | } | 831 | } |
832 | 832 | ||
833 | #[test] | 833 | #[test] |
834 | fn infer_pattern_match_ergonomics() { | ||
835 | assert_snapshot_matches!( | ||
836 | infer(r#" | ||
837 | struct A<T>(T); | ||
838 | |||
839 | fn test() { | ||
840 | let A(n) = &A(1); | ||
841 | let A(n) = &mut A(1); | ||
842 | } | ||
843 | "#), | ||
844 | @r###" | ||
845 | [28; 79) '{ ...(1); }': () | ||
846 | [38; 42) 'A(n)': A<i32> | ||
847 | [40; 41) 'n': &i32 | ||
848 | [45; 50) '&A(1)': &A<i32> | ||
849 | [46; 47) 'A': A<i32>(T) -> A<T> | ||
850 | [46; 50) 'A(1)': A<i32> | ||
851 | [48; 49) '1': i32 | ||
852 | [60; 64) 'A(n)': A<i32> | ||
853 | [62; 63) 'n': &mut i32 | ||
854 | [67; 76) '&mut A(1)': &mut A<i32> | ||
855 | [72; 73) 'A': A<i32>(T) -> A<T> | ||
856 | [72; 76) 'A(1)': A<i32> | ||
857 | [74; 75) '1': i32"### | ||
858 | ); | ||
859 | } | ||
860 | |||
861 | #[test] | ||
862 | fn infer_pattern_match_ergonomics_ref() { | ||
863 | covers!(match_ergonomics_ref); | ||
864 | assert_snapshot_matches!( | ||
865 | infer(r#" | ||
866 | fn test() { | ||
867 | let v = &(1, &2); | ||
868 | let (_, &w) = v; | ||
869 | } | ||
870 | "#), | ||
871 | @r###" | ||
872 | [11; 57) '{ ...= v; }': () | ||
873 | [21; 22) 'v': &(i32, &i32) | ||
874 | [25; 33) '&(1, &2)': &(i32, &i32) | ||
875 | [26; 33) '(1, &2)': (i32, &i32) | ||
876 | [27; 28) '1': i32 | ||
877 | [30; 32) '&2': &i32 | ||
878 | [31; 32) '2': i32 | ||
879 | [43; 50) '(_, &w)': (i32, &i32) | ||
880 | [44; 45) '_': i32 | ||
881 | [47; 49) '&w': &i32 | ||
882 | [48; 49) 'w': i32 | ||
883 | [53; 54) 'v': &(i32, &i32)"### | ||
884 | ); | ||
885 | } | ||
886 | |||
887 | #[test] | ||
834 | fn infer_adt_pattern() { | 888 | fn infer_adt_pattern() { |
835 | assert_snapshot_matches!( | 889 | assert_snapshot_matches!( |
836 | infer(r#" | 890 | infer(r#" |