aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-08-21 22:34:50 +0100
committerKirill Bulatov <[email protected]>2019-08-26 20:44:50 +0100
commit44386d5373114ffc88ef6bd182fb3b58a7c27e69 (patch)
tree19a1d277377ecf2ea9c5ca9232f019d20b53137d /crates/ra_hir/src/ty/tests.rs
parent89f3cc587d07a3cdcebf84cc4b99fe42636e66f0 (diff)
An attempt to add the coercion logic for Never
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs58
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 a30a645eb..4fa9d131d 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -3619,6 +3619,26 @@ fn test(a: i32) {
3619 } 3619 }
3620 3620
3621 #[test] 3621 #[test]
3622 fn match_second_block_arm_never() {
3623 let t = type_at(
3624 r#"
3625//- /main.rs
3626fn test(a: i32) {
3627 let i = match a {
3628 1 => { 3.0 },
3629 2 => { loop {} },
3630 3 => { 3.0 },
3631 _ => { return },
3632 };
3633 i<|>
3634 ()
3635}
3636"#,
3637 );
3638 assert_eq!(t, "f64");
3639 }
3640
3641 #[test]
3622 fn if_never() { 3642 fn if_never() {
3623 let t = type_at( 3643 let t = type_at(
3624 r#" 3644 r#"
@@ -3657,6 +3677,26 @@ fn test(input: bool) {
3657 } 3677 }
3658 3678
3659 #[test] 3679 #[test]
3680 fn match_first_block_arm_never() {
3681 let t = type_at(
3682 r#"
3683//- /main.rs
3684fn test(a: i32) {
3685 let i = match a {
3686 1 => { return },
3687 2 => { 2.0 },
3688 3 => { loop {} },
3689 _ => { 3.0 },
3690 };
3691 i<|>
3692 ()
3693}
3694"#,
3695 );
3696 assert_eq!(t, "f64");
3697 }
3698
3699 #[test]
3660 fn match_second_arm_never() { 3700 fn match_second_arm_never() {
3661 let t = type_at( 3701 let t = type_at(
3662 r#" 3702 r#"
@@ -3695,6 +3735,24 @@ fn test(a: i32) {
3695 } 3735 }
3696 3736
3697 #[test] 3737 #[test]
3738 fn match_all_block_arms_never() {
3739 let t = type_at(
3740 r#"
3741//- /main.rs
3742fn test(a: i32) {
3743 let i = match a {
3744 2 => { return },
3745 _ => { loop {} },
3746 };
3747 i<|>
3748 ()
3749}
3750"#,
3751 );
3752 assert_eq!(t, "!");
3753 }
3754
3755 #[test]
3698 fn match_no_never_arms() { 3756 fn match_no_never_arms() {
3699 let t = type_at( 3757 let t = type_at(
3700 r#" 3758 r#"