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:
@ -30,10 +30,8 @@ pub use frag::Frag;
|
||||
pub use branch_stub::BranchStub; // Phase 267 P0: 追加
|
||||
|
||||
// 合成関数(Phase 264: crate内のみ公開、Phase 265+でpub化)
|
||||
pub(crate) use compose::{seq, if_, loop_, cleanup};
|
||||
|
||||
// 検証関数
|
||||
pub use verify::verify_frag_invariants;
|
||||
// Phase 266: strict 版追加
|
||||
|
||||
// Phase 267 P0: wires + branches → MIR terminator 変換
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Phase 282 P5: Pattern3 (Loop with If-Else PHI) Extraction
|
||||
|
||||
use crate::ast::{ASTNode, BinaryOperator};
|
||||
use crate::ast::ASTNode;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct Pattern3Parts {
|
||||
|
||||
@ -19,5 +19,5 @@ mod promote_decision;
|
||||
mod promote_runner;
|
||||
|
||||
// Re-export the SSOT types and functions
|
||||
pub(in crate::mir::builder) use promote_decision::{PromoteDecision, PromoteStepResult};
|
||||
pub(in crate::mir::builder) use promote_decision::PromoteDecision;
|
||||
pub(in crate::mir::builder) use promote_runner::try_promote;
|
||||
|
||||
@ -61,14 +61,11 @@ impl NormalizedShadowSuffixRouterBox {
|
||||
}
|
||||
};
|
||||
|
||||
// Phase 142 P0: Accept both LoopOnly and LoopWithPost
|
||||
// Normalization unit is now "statement (loop 1個)", not "block suffix"
|
||||
// Phase 142 P0: Normalization unit is now "statement (loop only)", not "block suffix"
|
||||
if debug {
|
||||
let description = match &plan.kind {
|
||||
PlanKind::LoopOnly => "Loop-only pattern".to_string(),
|
||||
PlanKind::LoopWithPost { post_assign_count } => {
|
||||
format!("Loop+post pattern: {} post assigns", post_assign_count)
|
||||
}
|
||||
_ => "Unknown pattern (should not happen)".to_string(),
|
||||
};
|
||||
trace.routing("suffix_router", func_name, &description);
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ impl MirBuilder {
|
||||
};
|
||||
|
||||
// Only handle loop-only patterns here
|
||||
// (suffix patterns with post-statements go through suffix_router_box)
|
||||
// (post-statement patterns are now handled at statement level)
|
||||
match &plan.kind {
|
||||
PlanKind::LoopOnly => {
|
||||
if debug {
|
||||
@ -454,14 +454,13 @@ impl MirBuilder {
|
||||
);
|
||||
}
|
||||
}
|
||||
PlanKind::LoopWithPost { .. } => {
|
||||
// This should not happen in try_normalized_shadow context
|
||||
// (post patterns should be caught by suffix_router_box earlier)
|
||||
_ => {
|
||||
// Fallback for any other pattern (should not happen in Phase 142+)
|
||||
if debug {
|
||||
trace::trace().routing(
|
||||
"router/normalized",
|
||||
func_name,
|
||||
"Loop+post pattern in try_normalized_shadow (unexpected, using legacy)",
|
||||
"Unexpected pattern in try_normalized_shadow, using legacy",
|
||||
);
|
||||
}
|
||||
return Ok(None);
|
||||
|
||||
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user