Skip to main content

Module rules

Module rules 

Source
Expand description

引擎内置通用规则:只依赖 Lang 抽象,任何语言 crate 均可复用。

每条规则文档化其语义前提;所有提案都必须严格降低成本(runner 校验)。

Structs§

ArithIdentity
ArithReassoc
ArithZero
AssignBackFold
AssignPropagation
BitIdentity
BlockFlatten
块展平:Block 的直接孩子是 Block 且内层无任何声明(VarDecl/ ForEach/Catch 绑定引入作用域)→ 内层语句上提。典型形态:try 剥壳、 CFF 还原后的裸嵌套块。无声明 ⇒ 无遮蔽 ⇒ 语义等价。
BoolCompare
BoolNotFold
BoolShortCircuit
BooleanReturn
CmpConstFold
ConstCondition
ConstFoldBin
DeadDecl
DeadStore
DeclAssignMerge
DoubleNegFold
数值双重取负:-(-x) → x(补码回绕下恒等:-(-MIN) ≡ MIN ≡ x); -(-lit) → |lit|(解析器不折负字面量的外层负)。
DoubleNot
IfAssignTernary
IfElseEmpty
IfToTernary
InverseAssignPair
LocalPropagation
MultiUseCopyPropagation
NotCompare
ParenRemoval
SelfAssign
StoreKill
TernaryBool
TernaryBoolOp
TernaryFold
TrailingContinue
TrailingReturn
UnreachableAfterTerminal

Functions§

all_rules
全量规则(含 DCE 类选配项;按设计文档“可选配,默认不启用“)。
collect_stmt_kill_events
One DFS of a statement computing the dominating=true kill event for every name that has one. Recursion order matches scan_kill_event; the first event per name wins. Used by language crates to build a per-statement index so StoreKill does not rescan subtrees per candidate.
default_rules
默认规则(保守集:不做 DCE 类清理)。
scan_kill_event
扫描一个节点在 name 上的事件。 dominating:当前子树是否在必经路径上(If/While 的 cond、Ternary 的 cond、For 的 init/cond、非短路二元两侧 = true;分支体/循环体 = false)。