diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index f6a2a658f..1bd677cab 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -282,6 +282,64 @@ fn test() { | |||
282 | } | 282 | } |
283 | 283 | ||
284 | #[test] | 284 | #[test] |
285 | fn infer_path_type() { | ||
286 | assert_snapshot!( | ||
287 | infer(r#" | ||
288 | struct S; | ||
289 | |||
290 | impl S { | ||
291 | fn foo() -> i32 { 1 } | ||
292 | } | ||
293 | |||
294 | fn test() { | ||
295 | S::foo(); | ||
296 | <S>::foo(); | ||
297 | } | ||
298 | "#), | ||
299 | @r###" | ||
300 | [41; 46) '{ 1 }': i32 | ||
301 | [43; 44) '1': i32 | ||
302 | [60; 93) '{ ...o(); }': () | ||
303 | [66; 72) 'S::foo': fn foo() -> i32 | ||
304 | [66; 74) 'S::foo()': i32 | ||
305 | [80; 88) '<S>::foo': fn foo() -> i32 | ||
306 | [80; 90) '<S>::foo()': i32 | ||
307 | "### | ||
308 | ); | ||
309 | } | ||
310 | |||
311 | #[test] | ||
312 | fn infer_slice_method() { | ||
313 | assert_snapshot!( | ||
314 | infer(r#" | ||
315 | #[lang = "slice"] | ||
316 | impl<T> [T] { | ||
317 | fn foo(&self) -> T { | ||
318 | loop {} | ||
319 | } | ||
320 | } | ||
321 | |||
322 | #[lang = "slice_alloc"] | ||
323 | impl<T> [T] {} | ||
324 | |||
325 | fn test() { | ||
326 | <[_]>::foo(b"foo"); | ||
327 | } | ||
328 | "#), | ||
329 | @r###" | ||
330 | [45; 49) 'self': &[T] | ||
331 | [56; 79) '{ ... }': ! | ||
332 | [66; 73) 'loop {}': ! | ||
333 | [71; 73) '{}': () | ||
334 | [133; 160) '{ ...o"); }': () | ||
335 | [139; 149) '<[_]>::foo': fn foo<u8>(&[T]) -> T | ||
336 | [139; 157) '<[_]>:..."foo")': u8 | ||
337 | [150; 156) 'b"foo"': &[u8] | ||
338 | "### | ||
339 | ); | ||
340 | } | ||
341 | |||
342 | #[test] | ||
285 | fn infer_struct() { | 343 | fn infer_struct() { |
286 | assert_snapshot!( | 344 | assert_snapshot!( |
287 | infer(r#" | 345 | infer(r#" |