From b6497991e682b8c4a01dd4f3eed75710b2bc0ce2 Mon Sep 17 00:00:00 2001 From: Joel DSouza Date: Sun, 5 Jul 2026 21:52:32 +0200 Subject: [PATCH] docs(plan): sync #114 plan Parse example to shipped code (no input shadow) The #114 plan's Parse snippet shadowed `input`; the shipped derive_msg.rs binds the parsed AST to `derive` instead (god-level clippy bans shadow-reuse). Align the historical plan doc with what landed. --- .../2026-07-05-msg-model-size-tripwire.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/superpowers/plans/2026-07-05-msg-model-size-tripwire.md b/docs/superpowers/plans/2026-07-05-msg-model-size-tripwire.md index c4874df..0d6b2a1 100644 --- a/docs/superpowers/plans/2026-07-05-msg-model-size-tripwire.md +++ b/docs/superpowers/plans/2026-07-05-msg-model-size-tripwire.md @@ -460,9 +460,11 @@ Update `Parse` to read the budget: ```rust impl Parse for DeriveMsg { fn parse(input: ParseStream) -> syn::Result { - let input: DeriveInput = input.parse()?; - let budget = parse_budget(&input.attrs)?; - Ok(Self { ident: input.ident, budget }) + // Note: do NOT shadow `input` (god-level clippy bans `shadow-reuse`); + // bind the parsed AST to a distinct name. + let derive: DeriveInput = input.parse()?; + let budget = parse_budget(&derive.attrs)?; + Ok(Self { ident: derive.ident, budget }) } } ``` @@ -626,24 +628,25 @@ Replace the `Parse` impl with the validating version: ```rust impl Parse for DeriveMsg { fn parse(input: ParseStream) -> syn::Result { - let input: DeriveInput = input.parse()?; + // Do NOT shadow `input` (god-level clippy bans `shadow-reuse`). + let derive: DeriveInput = input.parse()?; - if let Some(param) = input.generics.params.first() { + if let Some(param) = derive.generics.params.first() { return Err(syn::Error::new_spanned( param, "`#[derive(Msg)]` needs a concrete type: the slot-size tripwire \ cannot size an unmonomorphized generic", )); } - if let Data::Union(data) = &input.data { + if let Data::Union(data) = &derive.data { return Err(syn::Error::new_spanned( data.union_token, "`#[derive(Msg)]` supports structs and enums, not unions", )); } - let budget = parse_budget(&input.attrs)?; - Ok(Self { ident: input.ident, budget }) + let budget = parse_budget(&derive.attrs)?; + Ok(Self { ident: derive.ident, budget }) } } ```