aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/match_check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/diagnostics/match_check.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/match_check.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs
index 5f0cc4145..061ef754d 100644
--- a/crates/hir_ty/src/diagnostics/match_check.rs
+++ b/crates/hir_ty/src/diagnostics/match_check.rs
@@ -1090,6 +1090,42 @@ fn main() {
1090 ); 1090 );
1091 } 1091 }
1092 1092
1093 #[test]
1094 fn enum_non_exhaustive() {
1095 check_diagnostics(
1096 r#"
1097//- /lib.rs crate:lib
1098#[non_exhaustive]
1099pub enum E { A, B }
1100fn _local() {
1101 match E::A { _ => {} }
1102 match E::A {
1103 E::A => {}
1104 E::B => {}
1105 }
1106 match E::A {
1107 E::A | E::B => {}
1108 }
1109}
1110
1111//- /main.rs crate:main deps:lib
1112use lib::E;
1113fn main() {
1114 match E::A { _ => {} }
1115 match E::A {
1116 //^^^^ Missing match arm
1117 E::A => {}
1118 E::B => {}
1119 }
1120 match E::A {
1121 //^^^^ Missing match arm
1122 E::A | E::B => {}
1123 }
1124}
1125"#,
1126 );
1127 }
1128
1093 mod false_negatives { 1129 mod false_negatives {
1094 //! The implementation of match checking here is a work in progress. As we roll this out, we 1130 //! The implementation of match checking here is a work in progress. As we roll this out, we
1095 //! prefer false negatives to false positives (ideally there would be no false positives). This 1131 //! prefer false negatives to false positives (ideally there would be no false positives). This