aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests/coercion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/tests/coercion.rs')
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index ac9e3872a..33d6ca403 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -440,3 +440,34 @@ fn test() {
440 "### 440 "###
441 ); 441 );
442} 442}
443
444#[test]
445fn closure_return_coerce() {
446 assert_snapshot!(
447 infer_with_mismatches(r#"
448fn foo() {
449 let x = || {
450 if true {
451 return &1u32;
452 }
453 &&1u32
454 };
455}
456"#, true),
457 @r###"
458 [10; 106) '{ ... }; }': ()
459 [20; 21) 'x': || -> &u32
460 [24; 103) '|| { ... }': || -> &u32
461 [27; 103) '{ ... }': &u32
462 [37; 82) 'if tru... }': ()
463 [40; 44) 'true': bool
464 [45; 82) '{ ... }': !
465 [59; 71) 'return &1u32': !
466 [66; 71) '&1u32': &u32
467 [67; 71) '1u32': u32
468 [91; 97) '&&1u32': &&u32
469 [92; 97) '&1u32': &u32
470 [93; 97) '1u32': u32
471 "###
472 );
473}