aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/diagnostics/match_check.rs29
-rw-r--r--crates/hir_ty/src/tests/simple.rs9
2 files changed, 20 insertions, 18 deletions
diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs
index fbe760c39..1c1423fbf 100644
--- a/crates/hir_ty/src/diagnostics/match_check.rs
+++ b/crates/hir_ty/src/diagnostics/match_check.rs
@@ -1495,6 +1495,20 @@ fn main(f: Foo) {
1495 ); 1495 );
1496 } 1496 }
1497 1497
1498 #[test]
1499 fn internal_or() {
1500 check_diagnostics(
1501 r#"
1502fn main() {
1503 enum Either { A(bool), B }
1504 match Either::B {
1505 //^^^^^^^^^ Missing match arm
1506 Either::A(true | false) => (),
1507 }
1508}
1509"#,
1510 );
1511 }
1498 mod false_negatives { 1512 mod false_negatives {
1499 //! The implementation of match checking here is a work in progress. As we roll this out, we 1513 //! The implementation of match checking here is a work in progress. As we roll this out, we
1500 //! prefer false negatives to false positives (ideally there would be no false positives). This 1514 //! prefer false negatives to false positives (ideally there would be no false positives). This
@@ -1521,20 +1535,5 @@ fn main() {
1521"#, 1535"#,
1522 ); 1536 );
1523 } 1537 }
1524
1525 #[test]
1526 fn internal_or() {
1527 // We do not currently handle patterns with internal `or`s.
1528 check_diagnostics(
1529 r#"
1530fn main() {
1531 enum Either { A(bool), B }
1532 match Either::B {
1533 Either::A(true | false) => (),
1534 }
1535}
1536"#,
1537 );
1538 }
1539 } 1538 }
1540} 1539}
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index ab21332fb..b364c2e58 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -2418,13 +2418,15 @@ fn infer_const_params() {
2418 2418
2419#[test] 2419#[test]
2420fn infer_inner_type() { 2420fn infer_inner_type() {
2421 check_infer(r#" 2421 check_infer(
2422 r#"
2422 fn foo() { 2423 fn foo() {
2423 struct S { field: u32 } 2424 struct S { field: u32 }
2424 let s = S { field: 0 }; 2425 let s = S { field: 0 };
2425 let f = s.field; 2426 let f = s.field;
2426 } 2427 }
2427 "#, expect![[r#" 2428 "#,
2429 expect![[r#"
2428 9..89 '{ ...eld; }': () 2430 9..89 '{ ...eld; }': ()
2429 47..48 's': S 2431 47..48 's': S
2430 51..65 'S { field: 0 }': S 2432 51..65 'S { field: 0 }': S
@@ -2432,5 +2434,6 @@ fn infer_inner_type() {
2432 75..76 'f': u32 2434 75..76 'f': u32
2433 79..80 's': S 2435 79..80 's': S
2434 79..86 's.field': u32 2436 79..86 's.field': u32
2435 "#]]); 2437 "#]],
2438 );
2436} 2439}