mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Fix text fixtures of missing_match_arms diagnostics
This commit is contained in:
parent
44e2c6ea92
commit
522823f610
3 changed files with 11 additions and 3 deletions
|
@ -398,7 +398,7 @@ impl<'a> InferenceContext<'a> {
|
||||||
for arm in arms.iter() {
|
for arm in arms.iter() {
|
||||||
self.diverges = Diverges::Maybe;
|
self.diverges = Diverges::Maybe;
|
||||||
let input_ty = self.resolve_ty_shallow(&input_ty);
|
let input_ty = self.resolve_ty_shallow(&input_ty);
|
||||||
let _pat_ty = self.infer_top_pat(arm.pat, &input_ty);
|
self.infer_top_pat(arm.pat, &input_ty);
|
||||||
if let Some(guard_expr) = arm.guard {
|
if let Some(guard_expr) = arm.guard {
|
||||||
self.infer_expr(
|
self.infer_expr(
|
||||||
guard_expr,
|
guard_expr,
|
||||||
|
|
|
@ -293,7 +293,8 @@ impl<'a> InferenceContext<'a> {
|
||||||
};
|
};
|
||||||
// use a new type variable if we got error type here
|
// use a new type variable if we got error type here
|
||||||
let ty = self.insert_type_vars_shallow(ty);
|
let ty = self.insert_type_vars_shallow(ty);
|
||||||
if !self.unify(&ty, &expected) {
|
// FIXME: This never check is odd, but required with out we do inference right now
|
||||||
|
if !expected.is_never() && !self.unify(&ty, &expected) {
|
||||||
self.result
|
self.result
|
||||||
.type_mismatches
|
.type_mismatches
|
||||||
.insert(pat.into(), TypeMismatch { expected, actual: ty.clone() });
|
.insert(pat.into(), TypeMismatch { expected, actual: ty.clone() });
|
||||||
|
|
|
@ -273,15 +273,20 @@ enum Either2 { C, D }
|
||||||
fn main() {
|
fn main() {
|
||||||
match Either::A {
|
match Either::A {
|
||||||
Either2::C => (),
|
Either2::C => (),
|
||||||
|
// ^^^^^^^^^^ error: expected Either, found Either2
|
||||||
Either2::D => (),
|
Either2::D => (),
|
||||||
|
// ^^^^^^^^^^ error: expected Either, found Either2
|
||||||
}
|
}
|
||||||
match (true, false) {
|
match (true, false) {
|
||||||
(true, false, true) => (),
|
(true, false, true) => (),
|
||||||
|
// ^^^^^^^^^^^^^^^^^^^ error: expected (bool, bool), found (bool, bool, bool)
|
||||||
(true) => (),
|
(true) => (),
|
||||||
// ^^^^ error: expected (bool, bool), found bool
|
// ^^^^ error: expected (bool, bool), found bool
|
||||||
}
|
}
|
||||||
match (true, false) { (true,) => {} }
|
match (true, false) { (true,) => {} }
|
||||||
|
// ^^^^^^^ error: expected (bool, bool), found (bool,)
|
||||||
match (0) { () => () }
|
match (0) { () => () }
|
||||||
|
// ^^ error: expected i32, found ()
|
||||||
match Unresolved::Bar { Unresolved::Baz => () }
|
match Unresolved::Bar { Unresolved::Baz => () }
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
|
@ -295,7 +300,9 @@ fn main() {
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match false { true | () => {} }
|
match false { true | () => {} }
|
||||||
|
// ^^ error: expected bool, found ()
|
||||||
match (false,) { (true | (),) => {} }
|
match (false,) { (true | (),) => {} }
|
||||||
|
// ^^ error: expected bool, found ()
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -1038,12 +1045,12 @@ fn main() {
|
||||||
#[test]
|
#[test]
|
||||||
fn reference_patterns_in_fields() {
|
fn reference_patterns_in_fields() {
|
||||||
cov_mark::check_count!(validate_match_bailed_out, 2);
|
cov_mark::check_count!(validate_match_bailed_out, 2);
|
||||||
|
|
||||||
check_diagnostics(
|
check_diagnostics(
|
||||||
r#"
|
r#"
|
||||||
fn main() {
|
fn main() {
|
||||||
match (&false,) {
|
match (&false,) {
|
||||||
(true,) => {}
|
(true,) => {}
|
||||||
|
// ^^^^^^^ error: expected (&bool,), found (bool,)
|
||||||
}
|
}
|
||||||
match (&false,) {
|
match (&false,) {
|
||||||
(&true,) => {}
|
(&true,) => {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue