From a54d1cfa07b5b2a91daaf04d7d8ada850b4a1d52 Mon Sep 17 00:00:00 2001 From: lauren Date: Wed, 20 May 2026 16:41:53 -0700 Subject: [PATCH] [rust-compiler] Fix non-exhaustive PatternLike match in scope_resolution test `cargo test -p react_compiler_ast` (and `cargo test --workspace`) fails to compile because the `visit_pat` helper in the scope_resolution integration test does not handle the four TS cast-wrapper variants of `PatternLike` (TSAsExpression, TSSatisfiesExpression, TSNonNullExpression, TSTypeAssertion) that were added to `PatternLike` in #36492 to support TS cast wrappers as assignment targets. Add the four missing arms, mirroring how `visit_expr` in the same file already handles these same wrapper types (descend into the inner expression with `visit_expr`; visit the type annotation JSON where present). Before this change: cargo test --workspace error[E0004]: non-exhaustive patterns: `&mut PatternLike::TSAsExpression(_)`, `&mut PatternLike::TSSatisfiesExpression(_)`, `&mut PatternLike::TSNonNullExpression(_)` and 1 more not covered After: cargo test --workspace TOTAL: 56 passed, 0 failed --- .../react_compiler_ast/tests/scope_resolution.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler/crates/react_compiler_ast/tests/scope_resolution.rs b/compiler/crates/react_compiler_ast/tests/scope_resolution.rs index 7131771e2ec8..6c5adbaaf1b3 100644 --- a/compiler/crates/react_compiler_ast/tests/scope_resolution.rs +++ b/compiler/crates/react_compiler_ast/tests/scope_resolution.rs @@ -746,6 +746,21 @@ fn visit_pat(pat: &mut PatternLike, si: &ScopeInfo) { visit_expr(&mut e.object, si); visit_expr(&mut e.property, si); } + PatternLike::TSAsExpression(e) => { + visit_expr(&mut e.expression, si); + visit_json(&mut e.type_annotation, si); + } + PatternLike::TSSatisfiesExpression(e) => { + visit_expr(&mut e.expression, si); + visit_json(&mut e.type_annotation, si); + } + PatternLike::TSNonNullExpression(e) => { + visit_expr(&mut e.expression, si); + } + PatternLike::TSTypeAssertion(e) => { + visit_expr(&mut e.expression, si); + visit_json(&mut e.type_annotation, si); + } } }