diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests/coercion.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests/coercion.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs index 793c23e41..7e99a42ed 100644 --- a/crates/ra_hir_ty/src/tests/coercion.rs +++ b/crates/ra_hir_ty/src/tests/coercion.rs | |||
@@ -487,3 +487,42 @@ fn foo() { | |||
487 | "### | 487 | "### |
488 | ); | 488 | ); |
489 | } | 489 | } |
490 | |||
491 | #[test] | ||
492 | fn coerce_fn_item_to_fn_ptr() { | ||
493 | assert_snapshot!( | ||
494 | infer_with_mismatches(r#" | ||
495 | fn foo(x: u32) -> isize { 1 } | ||
496 | fn test() { | ||
497 | let f: fn(u32) -> isize = foo; | ||
498 | } | ||
499 | "#, true), | ||
500 | @r###" | ||
501 | [8; 9) 'x': u32 | ||
502 | [25; 30) '{ 1 }': isize | ||
503 | [27; 28) '1': isize | ||
504 | [41; 79) '{ ...foo; }': () | ||
505 | [51; 52) 'f': fn(u32) -> isize | ||
506 | [73; 76) 'foo': fn foo(u32) -> isize | ||
507 | "### | ||
508 | ); | ||
509 | } | ||
510 | |||
511 | #[test] | ||
512 | fn coerce_closure_to_fn_ptr() { | ||
513 | assert_snapshot!( | ||
514 | infer_with_mismatches(r#" | ||
515 | fn test() { | ||
516 | let f: fn(u32) -> isize = |x| { 1 }; | ||
517 | } | ||
518 | "#, true), | ||
519 | @r###" | ||
520 | [11; 55) '{ ...1 }; }': () | ||
521 | [21; 22) 'f': fn(u32) -> isize | ||
522 | [43; 52) '|x| { 1 }': |u32| -> isize | ||
523 | [44; 45) 'x': u32 | ||
524 | [47; 52) '{ 1 }': isize | ||
525 | [49; 50) '1': isize | ||
526 | "### | ||
527 | ); | ||
528 | } | ||