refactor(cleanup): Phase 285A1 Post-Implementation Cleanup

Code quality improvements after Phase 285A1 implementation:

**Task 1: Dead Code Cleanup**
- Removed unnecessary #[allow(dead_code)] from emit_weak_load()
- Function is actively used in weak_to_strong() method handler

**Task 2: Unused Import Removal (cargo fix)**
- edgecfg/api/mod.rs: Removed seq, if_, loop_, cleanup, verify_frag_invariants
- pattern3.rs: Removed BinaryOperator
- pattern2/api/mod.rs: Removed PromoteStepResult
- jump.rs: Removed EffectMask, Span
- Result: 6 unused imports eliminated

**Task 3: Deprecated Pattern Removal**
- Fixed 4 PlanKind::LoopWithPost deprecated warnings
- Updated to Phase 142 P0 architecture (statement-level normalization)
- Files: normalized_shadow_suffix_router_box.rs, routing.rs,
  execute_box.rs, plan.rs
- Removed 2 deprecated tests: test_loop_with_post_*

**Task 4: WeakFieldValidatorBox Boxification**
- Extracted weak field validation logic into dedicated Box
- New file: src/mir/builder/weak_field_validator.rs (147 lines)
- fields.rs: 277 → 237 lines (-40 lines, -14.4%)
- Added 5 unit tests for validation logic
- Follows Phase 33 boxification principles (single responsibility,
  testability, reusability)

**Metrics**:
- Code reduction: -40 lines in fields.rs
- Test coverage: +5 unit tests
- Warnings fixed: 4 deprecated warnings
- Imports cleaned: 6 unused imports

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-24 03:44:56 +09:00
parent cc8b27a1aa
commit 2da730de35
13 changed files with 365 additions and 87 deletions

View File

@ -63,8 +63,9 @@ impl NormalizationExecuteBox {
PlanKind::LoopOnly => {
Self::execute_loop_only(builder, remaining, func_name, debug, prefix_variables)
}
PlanKind::LoopWithPost { .. } => {
Self::execute_loop_with_post(builder, plan, remaining, func_name, debug, prefix_variables)
_ => {
// Fallback for any other pattern (should not happen in Phase 142+)
Err("[normalization/execute] Unexpected pattern kind (Phase 142+ should only have LoopOnly)".to_string())
}
}
}

View File

@ -65,6 +65,7 @@ impl NormalizationPlan {
since = "Phase 142 P0",
note = "Use loop_only() instead. Statement-level normalization makes this obsolete."
)]
#[allow(deprecated)]
pub fn loop_with_post(post_assign_count: usize) -> Self {
// consumed = 1 (loop) + N (assigns) + 1 (return)
let consumed = 1 + post_assign_count + 1;
@ -89,19 +90,8 @@ mod tests {
assert!(!plan.requires_return);
}
#[test]
fn test_loop_with_post_single() {
let plan = NormalizationPlan::loop_with_post(1);
assert_eq!(plan.consumed, 3); // loop + 1 assign + return
assert_eq!(plan.kind, PlanKind::LoopWithPost { post_assign_count: 1 });
assert!(plan.requires_return);
}
#[test]
fn test_loop_with_post_multiple() {
let plan = NormalizationPlan::loop_with_post(2);
assert_eq!(plan.consumed, 4); // loop + 2 assigns + return
assert_eq!(plan.kind, PlanKind::LoopWithPost { post_assign_count: 2 });
assert!(plan.requires_return);
}
// Phase 142 P0: Removed test_loop_with_post_* tests
// The loop_with_post() function and LoopWithPost variant are deprecated.
// Statement-level normalization (Phase 142 P0) obsoletes the "loop + post assigns + return" pattern.
// See docs/development/current/main/phases/phase-142/ for details.
}