From c1f47c37886b5cba116ba99fa37977d51871eba4 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 12 Aug 2019 23:06:32 +0300 Subject: Add test marks --- crates/ra_hir/src/marks.rs | 5 +++++ crates/ra_hir/src/ty/infer.rs | 5 +++++ crates/ra_hir/src/ty/tests.rs | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/ra_hir/src/marks.rs b/crates/ra_hir/src/marks.rs index 5b15eee90..3795debc1 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 dc7101075..b310bf6bd 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 6bf56959d..7ec834836 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 -- cgit v1.2.3