Skip to content

Exclude macro-inserted attributes from ordering checks (#289) - #290

Merged
leynos merged 1 commit into
mainfrom
fix-function-attrs-async-trait
Jul 17, 2026
Merged

Exclude macro-inserted attributes from ordering checks (#289)#290
leynos merged 1 commit into
mainfrom
fix-function-attrs-async-trait

Conversation

@leynos

@leynos leynos commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

This branch stops function_attrs_follow_docs from misattributing macro-inserted attributes to the items a macro emits, fixing the async-trait false 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

Validation

Live validation against the real async-trait crate (not the mock UI fixture):

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 with main (the seven documented pre-existing localization/UI failures, tracked under #284).

Notes

The ui/pass_async_trait_trait.rs fixture'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.

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.
@leynos
leynos enabled auto-merge (squash) July 17, 2026 21:05

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1656c913-7808-4053-a020-3cd1d214c5ca

📥 Commits

Reviewing files that changed from the base of the PR and between 0676d1f and 1e4eac3.

📒 Files selected for processing (1)
  • crates/function_attrs_follow_docs/src/driver.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-function-attrs-async-trait

Comment @coderabbitai help to get the list of available commands.

codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

@leynos
leynos merged commit 1fd4520 into main Jul 17, 2026
9 checks passed
@leynos
leynos deleted the fix-function-attrs-async-trait branch July 17, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

function_attrs_follow_docs: async-trait false positive from the widened item-boundary rule, and allow/expect cannot suppress it

1 participant