mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Add test marks
This commit is contained in:
parent
0ce05633a1
commit
c1f47c3788
3 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue