From 2eaf79cfbb447156151cb5435eff5f14f41c40f7 Mon Sep 17 00:00:00 2001 From: CAD97 Date: Mon, 17 Aug 2020 13:19:15 -0400 Subject: Document missing match arm false positive This should already be guarded against (https://github.com/rust-analyzer/rust-analyzer/blob/d2212a49f6d447a14cdc87a9de2a4844e78b6905/crates/hir_ty/src/diagnostics/expr.rs#L225-L230) but it isn't preventing this false positive for some reason. --- crates/hir_ty/src/diagnostics/match_check.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates') diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs index 7f007f1d6..1602c3fb4 100644 --- a/crates/hir_ty/src/diagnostics/match_check.rs +++ b/crates/hir_ty/src/diagnostics/match_check.rs @@ -1335,6 +1335,25 @@ fn panic(a: Category, b: Category) { ); } + #[test] + fn unknown_type() { + check_diagnostics( + r#" +enum Option { Some(T), None } + +fn main() { + // FIXME: This is a false positive, as the `Never` type is not known here. + // `Never` is deliberately not defined so that it's an uninferred type. + match Option::::None { + None => (), + Some(never) => match never {}, + // ^^^^^ Missing match arm + } +} +"#, + ); + } + mod false_negatives { //! The implementation of match checking here is a work in progress. As we roll this out, we //! prefer false negatives to false positives (ideally there would be no false positives). This -- cgit v1.2.3