diff options
author | Florian Diebold <[email protected]> | 2018-12-26 20:28:05 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-04 17:28:43 +0000 |
commit | 226e31dae94f2c72f5cf650564e521b792793629 (patch) | |
tree | cf687d02c3b96e1146ad5ce6542786f240d01b2f /crates/ra_hir/src/ty | |
parent | fe6c4115f6c8bb5b5f276bafcbd9cc3fc1d504d1 (diff) |
Add test for self type inference
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 19 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/0007_self.txt | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 93bf431c4..fb53fcf0b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -134,6 +134,25 @@ fn test() -> &mut &f64 { | |||
134 | ); | 134 | ); |
135 | } | 135 | } |
136 | 136 | ||
137 | #[test] | ||
138 | fn infer_self() { | ||
139 | check_inference( | ||
140 | r#" | ||
141 | struct S; | ||
142 | |||
143 | impl S { | ||
144 | fn test(&self) { | ||
145 | self; | ||
146 | } | ||
147 | fn test2(self: &Self) { | ||
148 | self; | ||
149 | } | ||
150 | } | ||
151 | "#, | ||
152 | "0007_self.txt", | ||
153 | ); | ||
154 | } | ||
155 | |||
137 | fn infer(content: &str) -> String { | 156 | fn infer(content: &str) -> String { |
138 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 157 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
139 | let source_file = db.source_file(file_id); | 158 | let source_file = db.source_file(file_id); |
diff --git a/crates/ra_hir/src/ty/tests/data/0007_self.txt b/crates/ra_hir/src/ty/tests/data/0007_self.txt new file mode 100644 index 000000000..18cd796c2 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/0007_self.txt | |||
@@ -0,0 +1,4 @@ | |||
1 | [50; 54) 'self': [unknown] | ||
2 | [40; 61) '{ ... }': () | ||
3 | [88; 109) '{ ... }': () | ||
4 | [98; 102) 'self': [unknown] | ||