diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index b6c02cd80..a76925b58 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -68,6 +68,51 @@ fn test() { | |||
68 | ); | 68 | ); |
69 | } | 69 | } |
70 | 70 | ||
71 | #[test] | ||
72 | fn infer_struct() { | ||
73 | check_inference( | ||
74 | r#" | ||
75 | struct A { | ||
76 | b: B, | ||
77 | c: C, | ||
78 | } | ||
79 | struct B; | ||
80 | struct C(usize); | ||
81 | |||
82 | fn test() { | ||
83 | let c = C(1); | ||
84 | B; | ||
85 | let a: A = A { b: B, c: C(1) }; | ||
86 | a.b; | ||
87 | a.c; | ||
88 | } | ||
89 | "#, | ||
90 | "0004_struct.txt", | ||
91 | ); | ||
92 | } | ||
93 | |||
94 | #[test] | ||
95 | fn infer_refs_and_ptrs() { | ||
96 | check_inference( | ||
97 | r#" | ||
98 | fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | ||
99 | a; | ||
100 | *a; | ||
101 | &a; | ||
102 | &mut a; | ||
103 | b; | ||
104 | *b; | ||
105 | &b; | ||
106 | c; | ||
107 | *c; | ||
108 | d; | ||
109 | *d; | ||
110 | } | ||
111 | "#, | ||
112 | "0005_refs.txt", | ||
113 | ); | ||
114 | } | ||
115 | |||
71 | fn infer(content: &str) -> String { | 116 | fn infer(content: &str) -> String { |
72 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 117 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
73 | let source_file = db.source_file(file_id); | 118 | let source_file = db.source_file(file_id); |