You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
may_name_constant misses constants declared by item macros, so a macro-made constant pattern can read exposed #7863
macro_rules! def_const {($n:ident) => {const $n:i64 = 0;};}def_const!(p);pubfntier(points:i64) -> Tier{match points {
p if100 < p => Tier::Gold,// edited from `p if 100 <= p`
p if p >= 50 => Tier::Silver,
_ => Tier::Bronze,}}// tests: tier(99), tier(100), tier(101), tier(400) with exact asserts
Observed: the guard's predicate finding reads exposed. That is false: p is the constant 0, the arm only matches points == 0, and no test separates the two guards.
Cause
may_name_constant (crates/ripr/src/analysis/classify/arm_selection.rs) recognizes const/static written before the name, and use imports. Item names from macro_rules! are not hygienic, so def_const!(p) declares a constant p that this check cannot see. The same applies to a crate macro defined in another file. Both consumers are affected: arm-selection binding demotion (demote_constant_bindings) and, since #7811, the guard-binding alias in activation.rs.
Goal it hurts
Trustworthy verdicts: a false exposed is the worst outcome.
Suggested fix
Fail closed when the owner file has any item-level macro call, matching how declared_enum_variants treats item macros. Then add this repro as a control for both consumers.
Found by adversarial review of #7811 (non-blocking there: the code is unusual).
Activity
Answer #7922 review: macro constants, let guards, compound guards
fix(arm-selection): close three more false-exposed guard-alias paths (#…
EffortlessSteven commentedon Oct 17, 2026
Claiming: fixing in a draft PR (branch claude/issue-7863).
Generated by Claude Code
fix(arm-selection): an item macro may declare a constant a bare arm b…