diff --git a/crates/ra_hir/src/marks.rs b/crates/ra_hir/src/marks.rs index 5b15eee901..3795debc1a 100644 --- a/crates/ra_hir/src/marks.rs +++ b/crates/ra_hir/src/marks.rs @@ -11,4 +11,9 @@ test_utils::marks!( match_ergonomics_ref trait_resolution_on_fn_type infer_while_let + match_complex_arm_ty + match_first_arm_never + match_second_arm_never + match_all_arms_never + match_no_never_arms ); diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index dc71010759..b310bf6bd6 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -1096,8 +1096,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { } let arm_ty = self.infer_expr(arm.expr, &expected); if all_arms_never && Self::is_never(&arm_ty) { + tested_by!(match_first_arm_never); resulting_match_ty = Some(arm_ty); } else { + tested_by!(match_second_arm_never); all_arms_never = false; resulting_match_ty = None; } @@ -1106,10 +1108,13 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { if let (Ty::Infer(expected_tv), Some(match_ty)) = (&expected.ty, &resulting_match_ty) { + tested_by!(match_all_arms_never); self.var_unification_table .union_value(expected_tv.to_inner(), TypeVarValue::Known(match_ty.clone())); match_ty.clone() } else { + tested_by!(match_no_never_arms); + tested_by!(match_complex_arm_ty); expected.ty } } diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 6bf56959d8..7ec834836c 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -3595,12 +3595,13 @@ fn no_such_field_diagnostics() { ); } -#[cfg(test)] mod match_with_never_tests { use super::type_at; + use test_utils::covers; #[test] fn match_complex_arm_ty() { + covers!(match_complex_arm_ty); let t = type_at( r#" //- /main.rs @@ -3624,6 +3625,7 @@ fn test(a: i32) { #[test] fn match_first_arm_never() { + covers!(match_first_arm_never); let t = type_at( r#" //- /main.rs @@ -3644,6 +3646,7 @@ fn test(a: i32) { #[test] fn match_second_arm_never() { + covers!(match_second_arm_never); let t = type_at( r#" //- /main.rs @@ -3664,6 +3667,7 @@ fn test(a: i32) { #[test] fn match_all_arms_never() { + covers!(match_all_arms_never); let t = type_at( r#" //- /main.rs @@ -3682,6 +3686,7 @@ fn test(a: i32) { #[test] fn match_no_never_arms() { + covers!(match_no_never_arms); let t = type_at( r#" //- /main.rs