diff options
author | Florian Diebold <[email protected]> | 2019-01-07 12:44:54 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-12 14:01:19 +0000 |
commit | 082ef52bcb15d779c6aff78d9860d328bf7df9b2 (patch) | |
tree | a4a123ad491e15c8d17bdc815675d43bb33811b5 /crates/ra_hir/src/ty/tests.rs | |
parent | e9e397e705ad0bec9775067b10109e35ebefc493 (diff) |
Implement basic inherent method resolution
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 815aecda7..1c3129441 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -242,6 +242,32 @@ fn test() { | |||
242 | ); | 242 | ); |
243 | } | 243 | } |
244 | 244 | ||
245 | #[test] | ||
246 | fn infer_inherent_method() { | ||
247 | check_inference( | ||
248 | r#" | ||
249 | struct A; | ||
250 | |||
251 | impl A { | ||
252 | fn foo(self, x: u32) -> i32 {} | ||
253 | } | ||
254 | |||
255 | mod b { | ||
256 | impl super::A { | ||
257 | fn bar(&self, x: u64) -> i64 {} | ||
258 | } | ||
259 | } | ||
260 | |||
261 | fn test(a: A) { | ||
262 | a.foo(1); | ||
263 | (&a).bar(1); | ||
264 | a.bar(1); | ||
265 | } | ||
266 | "#, | ||
267 | "inherent_method.txt", | ||
268 | ); | ||
269 | } | ||
270 | |||
245 | fn infer(content: &str) -> String { | 271 | fn infer(content: &str) -> String { |
246 | let (db, _, file_id) = MockDatabase::with_single_file(content); | 272 | let (db, _, file_id) = MockDatabase::with_single_file(content); |
247 | let source_file = db.source_file(file_id); | 273 | let source_file = db.source_file(file_id); |