aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 7ec834836..94b0fe3b3 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -3595,7 +3595,7 @@ fn no_such_field_diagnostics() {
3595 ); 3595 );
3596} 3596}
3597 3597
3598mod match_with_never_tests { 3598mod branching_with_never_tests {
3599 use super::type_at; 3599 use super::type_at;
3600 use test_utils::covers; 3600 use test_utils::covers;
3601 3601
@@ -3645,6 +3645,46 @@ fn test(a: i32) {
3645 } 3645 }
3646 3646
3647 #[test] 3647 #[test]
3648 fn if_never() {
3649 covers!(if_never);
3650 let t = type_at(
3651 r#"
3652//- /main.rs
3653fn test() {
3654 let i = if true {
3655 loop {}
3656 } else {
3657 3.0
3658 };
3659 i<|>
3660 ()
3661}
3662"#,
3663 );
3664 assert_eq!(t, "f64");
3665 }
3666
3667 #[test]
3668 fn if_else_never() {
3669 covers!(if_else_never);
3670 let t = type_at(
3671 r#"
3672//- /main.rs
3673fn test(input: bool) {
3674 let i = if input {
3675 2.0
3676 } else {
3677 return
3678 };
3679 i<|>
3680 ()
3681}
3682"#,
3683 );
3684 assert_eq!(t, "f64");
3685 }
3686
3687 #[test]
3648 fn match_second_arm_never() { 3688 fn match_second_arm_never() {
3649 covers!(match_second_arm_never); 3689 covers!(match_second_arm_never);
3650 let t = type_at( 3690 let t = type_at(