Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/codegen/src/compile.rs`:
- Around line 8728-8731: The current check only sees root-level OR patterns by
testing has_match_or_case over m.pattern with matches!(...,
ast::Pattern::MatchOr(_)); implement a recursive detector (e.g.,
contains_match_or(pattern: &ast::Pattern) -> bool) that walks all pattern
variants and returns true if any nested ast::Pattern::MatchOr is found, then
replace the .any(...) calls (including the similar check at the later block
around the 8788-8793 area) to use contains_match_or(&m.pattern) so nested forms
like [1 | 2, x] or Foo(bar=1 | 2) are correctly detected.
- Around line 1096-1099: The helper statements_end_with_conditional currently
only checks for a top-level ast::Stmt::If; broaden it to treat other conditional
shapes (e.g., ast::Stmt::Match) and container statements whose inner body ends
with a conditional (e.g., ast::Stmt::With whose body.last() is an If, nested
blocks, etc.) by making statements_end_with_conditional recursively inspect the
last statement: return true for If or Match, and for With (and other block-like
stmts) call the same helper on their inner body(s); update any call sites
(notably the final-body layout logic that uses statements_end_with_conditional)
to rely on this expanded predicate so trailing match/with-nested-if forms are
recognized as conditional finalizers.
In `@crates/codegen/src/ir.rs`:
- Around line 10882-10898: The current booleans
has_nointerrupt_jump_to_last_block and
has_lineful_return_fallthrough_to_last_block are global to the function and
incorrectly suppress duplication for all predecessors of last_block; change them
to be edge-specific by computing these predicates per predecessor (or per (pred,
last_block) edge) instead of once for the whole function. Concretely, replace
the top-level uses of has_nointerrupt_jump_to_last_block and
has_lineful_return_fallthrough_to_last_block with code that for each predecessor
block computes: scan that predecessor's instructions with jump_thread_kind(...)
== Some(JumpThreadKind::NoInterrupt) and target==last_block (using
next_nonempty_block to compare), and check whether the specific predecessor's
fallthrough (block.next) ends with a lineful ReturnValue (use
instruction_lineno(...) and matches!(instr.instr.real(),
Some(Instruction::ReturnValue))). Do the same edge-specific refactor at the
other occurrence referenced (lines ~10924-10948), so suppression decisions are
made per-edge rather than function-wide.
- Around line 10787-10798: The current pattern in
ends_with_line_marker_implicit_return(block: &Block) uses [.., marker, load,
ret] which will match blocks that have real instructions before the suffix;
change the match so we only consider truly empty epilogues by requiring the
block be exactly [marker, load, ret] or, if you want to allow only padding nops,
add a guard that verifies all instructions before marker are non-real padding
(e.g. instr.real() is None or Instruction::Nop and/or have the appropriate
no-location flags) before retargeting; update the match and/or add that extra
guard around marker, load, ret to avoid skipping earlier real instructions.