Skip to content

Commit 91c4318

Browse files
olwangclaude
andcommitted
feat(selfhost): add RS0021 (NON_EXHAUSTIVE_MATCH) to the rss checker
Port match-exhaustiveness (crate::analyzer::exhaustiveness, simplified for the corpus) into selfhost/check.rss as the 17th parity code. A match statement or expression is non-exhaustive unless a guardless arm set covers its scrutinee: Some/None (Option), Ok/Err (Result), true/false (Bool), every variant of a declared sum, an irrefutable pattern for a single-constructor tuple/struct, a capping rest pattern for List, or a `_` wildcard. Malformed (no `=>`) and guarded arms contribute no coverage. Scrutinee root inference mirrors hir_expr_type_name: a let-bound local resolves through its RHS (constructor / unqualified-fn return type), a param through its declared type, qualified calls and `?`-unwrapped expressions fall back to the builtin Some/None|Ok/Err rule. Copies find_top_sym/find_top_if/is_kw_text from astdump; the arm walk reuses next_line_or_block_end. Real sum decls are distinguished from a variable literally named `sum` (the lexer tags every "sum" text with WORD_SUM) via a line-start/`pub`-guarded probe. checker_parity_corpus: 619/619, 0 mismatches, 0 run-failures (17 codes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 183e10a commit 91c4318

2 files changed

Lines changed: 606 additions & 2 deletions

File tree

crates/rsscript/src/selfhost_parity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ fn parser_parity_corpus() {
503503
// ---------------------------------------------------------------------------
504504

505505
/// Diagnostic codes the rss checker is expected to reproduce.
506-
const CHECKER_TARGET_CODES: &[&str] = &["RS0002","RS0003","RS0004","RS0005","RS0006","RS0007","RS0008","RS0009","RS0010","RS0011","RS0012","RS0016","RS0017","RS0024","RS0028","RS0033"];
506+
const CHECKER_TARGET_CODES: &[&str] = &["RS0002","RS0003","RS0004","RS0005","RS0006","RS0007","RS0008","RS0009","RS0010","RS0011","RS0012","RS0016","RS0017","RS0021","RS0024","RS0028","RS0033"];
507507

508508
fn is_target_code(code: &str) -> bool {
509509
CHECKER_TARGET_CODES.contains(&code)

0 commit comments

Comments
 (0)