From 29150c23153ecb611d7c578a5d63fef87a97de42 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 3 Mar 2023 21:34:00 +0100 Subject: [PATCH] Disable pattern type mismatches again --- crates/hir/src/lib.rs | 3 +++ crates/ide-diagnostics/src/handlers/missing_match_arms.rs | 8 -------- crates/ide-diagnostics/src/handlers/type_mismatch.rs | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 269c45943e..20009698f9 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1466,6 +1466,9 @@ impl DefWithBody { for (pat_or_expr, mismatch) in infer.type_mismatches() { let expr_or_pat = match pat_or_expr { ExprOrPatId::ExprId(expr) => source_map.expr_syntax(expr).map(Either::Left), + // FIXME: Re-enable these once we have less false positives + ExprOrPatId::PatId(_pat) => continue, + #[allow(unreachable_patterns)] ExprOrPatId::PatId(pat) => source_map.pat_syntax(pat).map(Either::Right), }; let expr_or_pat = match expr_or_pat { diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs index 6594eed26d..5ded2f2230 100644 --- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs +++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs @@ -273,20 +273,15 @@ enum Either2 { C, D } fn main() { match Either::A { Either2::C => (), - // ^^^^^^^^^^ error: expected Either, found Either2 Either2::D => (), - // ^^^^^^^^^^ error: expected Either, found Either2 } match (true, false) { (true, false, true) => (), - // ^^^^^^^^^^^^^^^^^^^ error: expected (bool, bool), found (bool, bool, bool) (true) => (), // ^^^^ error: expected (bool, bool), found bool } match (true, false) { (true,) => {} } - // ^^^^^^^ error: expected (bool, bool), found (bool,) match (0) { () => () } - // ^^ error: expected i32, found () match Unresolved::Bar { Unresolved::Baz => () } } "#, @@ -300,9 +295,7 @@ fn main() { r#" fn main() { match false { true | () => {} } - // ^^ error: expected bool, found () match (false,) { (true | (),) => {} } - // ^^ error: expected bool, found () } "#, ); @@ -1050,7 +1043,6 @@ fn main() { fn main() { match (&false,) { (true,) => {} - // ^^^^^^^ error: expected (&bool,), found (bool,) } match (&false,) { (&true,) => {} diff --git a/crates/ide-diagnostics/src/handlers/type_mismatch.rs b/crates/ide-diagnostics/src/handlers/type_mismatch.rs index 2026a2d4b8..b57a13e53e 100644 --- a/crates/ide-diagnostics/src/handlers/type_mismatch.rs +++ b/crates/ide-diagnostics/src/handlers/type_mismatch.rs @@ -617,10 +617,8 @@ fn f() -> i32 { r#" fn f() { let &() = &mut (); - //^^^ error: expected &mut (), found &() match &() { &9 => () - //^^ error: expected &(), found &i32 //^ error: expected (), found i32 } }