Exclude macro-inserted attributes from ordering checks (#289) - #290
Conversation
The widened item-boundary rule from #286 accepts attribute spans that precede the item, because modern nightlies exclude outer attributes from the item span. Attributes inserted by macro expansion carry spans whose call site resolves to the macro attribute on an enclosing item, so that rule misattributed, for example, a trait's `#[async_trait]` attribute to every method the macro emits — flagging correctly ordered docs on all methods of an `async-trait` trait. Drop attributes whose span carries an expansion context before the ordering comparison: the user did not write them at that position and cannot reorder them. User-written attributes passed through a macro keep their original spans and still participate, so genuine misorderings inside an `#[async_trait]` body are still caught. Verified against the real `async-trait` crate: a correctly ordered trait produces no findings; misordered attributes inside and outside the macro body still fire; and `#[allow]`/`#[expect]` suppress at item, module, and crate scope — the suppression failures reported in #289 were downstream of the expansion-anchored false positive.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 43 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
This branch stops
function_attrs_follow_docsfrom misattributing macro-inserted attributes to the items a macro emits, fixing theasync-traitfalse positive that is blocking the installer 0.2.6 pin-bump PRs on dear-diary (#61) and wireframe (#613).Closes #289.
The widened item-boundary rule from #286 accepts attribute spans preceding the item (modern nightlies exclude outer attributes from item spans). Attributes inserted by macro expansion resolve, via call-site recovery, to the macro attribute on an enclosing item — so a trait's
#[async_trait]was reported as a misordered outer attribute on every method, with correctly ordered source. The fix drops attributes whose span carries an expansion context before the ordering comparison: the user did not write them at that position and cannot reorder them.Review walkthrough
AttrInfo::try_from_hirnow returnsNonefor spans with an expansion context, alongside the existing dummy-span rejection.Validation
Live validation against the real
async-traitcrate (not the mock UI fixture):#[async_trait]body still fires (pass-through tokens keep their original spans);#[allow(function_attrs_follow_docs)]and#[expect(...)]suppress at item, module, and crate scope — the suppression failures reported in function_attrs_follow_docs: async-trait false positive from the widened item-boundary rule, and allow/expect cannot suppress it #289 were downstream of the expansion-anchored false positive.Gates: check-fmt, lint (clippy
-D warnings), typecheck, test (1459/1459, 3 skipped), markdownlint, and nixie all pass. The crate's own suite holds exact failure parity withmain(the seven documented pre-existing localization/UI failures, tracked under #284).Notes
The
ui/pass_async_trait_trait.rsfixture's mock macro already inserts a call-site-spanned attribute — the exact poison shape — so it serves as the in-tree regression fixture once the UI harness (currently among the documented pre-existing failures) is re-enabled.