Skip to content

refactor(semantic, transformer, react_compiler): use if-let match guards#24383

Merged
graphite-app[bot] merged 1 commit into
mainfrom
refactor-if-let-guards
Jul 11, 2026
Merged

refactor(semantic, transformer, react_compiler): use if-let match guards#24383
graphite-app[bot] merged 1 commit into
mainfrom
refactor-if-let-guards

Conversation

@Boshen

@Boshen Boshen commented Jul 11, 2026

Copy link
Copy Markdown
Member

Rust 1.95 stabilized if-let guards in match arms (MSRV bumped in #24359). This converts the three places which guard on is_some() and then re-extract the same value in the body — the guard now binds the value directly:

  • oxc_semantic binder.rsexport_decl.declaration.is_some() guard followed by .as_ref().unwrap().
  • oxc_transformer typescript/annotations.rsdecl.declaration.is_some() guard followed by an is_some_and re-check.
  • oxc_react_compiler validate_preserved_manual_memoization.rsstate.manual_memo_state.is_some() guard followed by .as_mut().unwrap(); the guard now binds &mut directly. The sibling StoreLocal arm used the same unwrap idiom in a body if, converted to a let chain for consistency.

I audited the other ~15 is_some() match guards in the workspace: they only test the value without extracting it in the body, so they stay as plain guards.

Verified: crate tests pass, semantic coverage suites and Babel transform conformance produce zero snapshot diffs, clippy clean for the changed files.

🤖 Generated with Claude Code

@Boshen
Boshen requested a review from Dunqing as a code owner July 11, 2026 10:58
@github-actions github-actions Bot added A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler labels Jul 11, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing refactor-if-let-guards (148dad4) with main (d117011)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jul 11, 2026

Boshen commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

Merge activity

…rds (#24383)

Rust 1.95 stabilized if-let guards in match arms (MSRV bumped in #24359). This converts the three places which guard on `is_some()` and then re-extract the same value in the body — the guard now binds the value directly:

- `oxc_semantic` `binder.rs` — `export_decl.declaration.is_some()` guard followed by `.as_ref().unwrap()`.
- `oxc_transformer` `typescript/annotations.rs` — `decl.declaration.is_some()` guard followed by an `is_some_and` re-check.
- `oxc_react_compiler` `validate_preserved_manual_memoization.rs` — `state.manual_memo_state.is_some()` guard followed by `.as_mut().unwrap()`; the guard now binds `&mut` directly. The sibling `StoreLocal` arm used the same unwrap idiom in a body `if`, converted to a let chain for consistency.

I audited the other ~15 `is_some()` match guards in the workspace: they only test the value without extracting it in the body, so they stay as plain guards.

Verified: crate tests pass, semantic coverage suites and Babel transform conformance produce **zero snapshot diffs**, clippy clean for the changed files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app
graphite-app Bot force-pushed the refactor-if-let-guards branch from 148dad4 to b6d2a29 Compare July 11, 2026 11:11
@graphite-app
graphite-app Bot merged commit b6d2a29 into main Jul 11, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jul 11, 2026
@graphite-app
graphite-app Bot deleted the refactor-if-let-guards branch July 11, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant