Skip to content

Conversation

@vishnupoddar12
Copy link
Contributor

@vishnupoddar12 vishnupoddar12 commented Feb 2, 2026

The [allow_attributes] lint false-negatived (failed to trigger) on attributes that contained internal whitespace, such as #[ allow ( dead_code ) ].

This happened because clippy_utils::is_from_proc_macro relied on strict string matching (e.g., expecting exactly #[allow), which fails if there are spaces.

Solution:

I have updated clippy_utils::is_from_proc_macro to support flexible whitespace matching.

  1. Added Pat::Attr(Symbol).
  2. Updated span_matches_pat to strip #[ and trim validation whitespace before checking the name.

Verified with a new test case in tests/ui/allow_attributes.rs.

Fixes #16491


changelog: [allow_attributes]: correctly detect attributes with internal whitespace

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2026

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!

View changes since this review

@llogiq llogiq added this pull request to the merge queue Feb 2, 2026
Merged via the queue into rust-lang:master with commit 301aae6 Feb 2, 2026
15 of 17 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 2, 2026
@vishnupoddar12 vishnupoddar12 deleted the issue-16491-fix branch February 2, 2026 08:28
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.

allow_attributes lint doesn't detect attributes with whitespace inside brackets

3 participants