diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-06 14:46:03 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-06 14:46:03 +0000 |
commit | 995a92814ffda2e9c4b46392c6293bbdce4b3cc1 (patch) | |
tree | 384f143b6f5454a6ff515ab387b2fc1a9d44bf29 /crates/ra_hir_ty/src/tests | |
parent | 13879afdd58f7cd9fe34843c5b09ba9c22de1e77 (diff) | |
parent | 073a1ef834be5e2e1ae6733c6c299d2ae68050d8 (diff) |
Merge #3490
3490: Support aliases and Self in struct literals r=matklad a=flodiebold
Fixes #3306.
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index 3803f5938..c140bd513 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -51,6 +51,47 @@ fn test() { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | #[test] | 53 | #[test] |
54 | fn self_in_struct_lit() { | ||
55 | assert_snapshot!(infer( | ||
56 | r#" | ||
57 | //- /main.rs | ||
58 | struct S<T> { x: T } | ||
59 | |||
60 | impl S<u32> { | ||
61 | fn foo() { | ||
62 | Self { x: 1 }; | ||
63 | } | ||
64 | } | ||
65 | "#, | ||
66 | ), @r###" | ||
67 | [63; 93) '{ ... }': () | ||
68 | [73; 86) 'Self { x: 1 }': S<u32> | ||
69 | [83; 84) '1': u32 | ||
70 | "###); | ||
71 | } | ||
72 | |||
73 | #[test] | ||
74 | fn type_alias_in_struct_lit() { | ||
75 | assert_snapshot!(infer( | ||
76 | r#" | ||
77 | //- /main.rs | ||
78 | struct S<T> { x: T } | ||
79 | |||
80 | type SS = S<u32>; | ||
81 | |||
82 | fn foo() { | ||
83 | SS { x: 1 }; | ||
84 | } | ||
85 | |||
86 | "#, | ||
87 | ), @r###" | ||
88 | [64; 84) '{ ...1 }; }': () | ||
89 | [70; 81) 'SS { x: 1 }': S<u32> | ||
90 | [78; 79) '1': u32 | ||
91 | "###); | ||
92 | } | ||
93 | |||
94 | #[test] | ||
54 | fn infer_ranges() { | 95 | fn infer_ranges() { |
55 | let (db, pos) = TestDB::with_position( | 96 | let (db, pos) = TestDB::with_position( |
56 | r#" | 97 | r#" |