(stmt: &ast::StmtMatch, ctx: &Ctx)
| 822 | } |
| 823 | |
| 824 | fn irrefutable_match_case<Ctx: SemanticSyntaxContext>(stmt: &ast::StmtMatch, ctx: &Ctx) { |
| 825 | // test_ok irrefutable_case_pattern_at_end |
| 826 | // match x: |
| 827 | // case 2: ... |
| 828 | // case var: ... |
| 829 | // match x: |
| 830 | // case 2: ... |
| 831 | // case _: ... |
| 832 | // match x: |
| 833 | // case var if True: ... # don't try to refute a guarded pattern |
| 834 | // case 2: ... |
| 835 | |
| 836 | // test_err irrefutable_case_pattern |
| 837 | // match x: |
| 838 | // case var: ... # capture pattern |
| 839 | // case 2: ... |
| 840 | // match x: |
| 841 | // case _: ... |
| 842 | // case 2: ... # wildcard pattern |
| 843 | // match x: |
| 844 | // case var1 as var2: ... # as pattern with irrefutable left-hand side |
| 845 | // case 2: ... |
| 846 | // match x: |
| 847 | // case enum.variant | var: ... # or pattern with irrefutable part |
| 848 | // case 2: ... |
| 849 | for case in stmt |
| 850 | .cases |
| 851 | .iter() |
| 852 | .rev() |
| 853 | .skip(1) |
| 854 | .filter_map(|case| match case.guard { |
| 855 | Some(_) => None, |
| 856 | None => case.pattern.irrefutable_pattern(), |
| 857 | }) |
| 858 | { |
| 859 | Self::add_error( |
| 860 | ctx, |
| 861 | SemanticSyntaxErrorKind::IrrefutableCasePattern(case.kind), |
| 862 | case.range, |
| 863 | ); |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | /// Check `stmt` for semantic syntax errors and update the checker's internal state. |
| 868 | /// |
nothing calls this directly
no test coverage detected