diff options
author | Florian Diebold <[email protected]> | 2019-01-06 18:51:42 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-07 13:54:23 +0000 |
commit | 7bb279b365e54ee0051e09ead5aa157ff6be917b (patch) | |
tree | 7a495d68453ea1e3c7a726e97bbbe19f9bc90532 /crates/ra_hir/src/ty/tests.rs | |
parent | a6071c9f4c8441b4b8f2e970bc055d66cc9be5f0 (diff) |
Implement autoderef for field accesses
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 83aedaa00..e6c7e225b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -95,7 +95,7 @@ fn test() { | |||
95 | } | 95 | } |
96 | 96 | ||
97 | #[test] | 97 | #[test] |
98 | fn infer_refs_and_ptrs() { | 98 | fn infer_refs() { |
99 | check_inference( | 99 | check_inference( |
100 | r#" | 100 | r#" |
101 | fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | 101 | fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { |
@@ -180,6 +180,37 @@ fn test() { | |||
180 | ); | 180 | ); |
181 | } | 181 | } |
182 | 182 | ||
183 | #[test] | ||
184 | fn infer_field_autoderef() { | ||
185 | check_inference( | ||
186 | r#" | ||
187 | struct A { | ||
188 | b: B, | ||
189 | } | ||
190 | struct B; | ||
191 | |||
192 | fn test1(a: A) { | ||
193 | let a1 = a; | ||
194 | a1.b; | ||
195 | let a2 = &a; | ||
196 | a2.b; | ||
197 | let a3 = &mut a; | ||
198 | a3.b; | ||
199 | let a4 = &&&&&&&a; | ||
200 | a4.b; | ||
201 | let a5 = &mut &&mut &&mut a; | ||
202 | a5.b; | ||
203 | } | ||
204 | |||
205 | fn test2(a1: *const A, a2: *mut A) { | ||
206 | a1.b; | ||
207 | a2.b; | ||
208 | } | ||
209 | "#, | ||
210 | "field_autoderef.txt", | ||
211 | ); | ||
212 | } | ||
213 | |||
183 | fn infer(content: &str) -> String { | 214 | fn infer(content: &str) -> String { |
184 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 215 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
185 | let source_file = db.source_file(file_id); | 216 | let source_file = db.source_file(file_id); |