Skip to content

fix(disallowed_macros): Fix emitting on attr macros #15452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

2asoft
Copy link

@2asoft 2asoft commented Aug 10, 2025

changelog: [disallowed_macros]: Fix emitting on attr macros. Fixes #14017.

@rustbot
Copy link
Collaborator

rustbot commented Aug 10, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 10, 2025
@2asoft 2asoft force-pushed the 2asoft/clippy_i14017 branch from 827b00d to 5b3451a Compare August 10, 2025 17:25
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &Attribute) {
let span = match attr {
Attribute::Unparsed(attr_item) => attr_item.span,
Attribute::Parsed(kind) => match kind {
Copy link
Author

@2asoft 2asoft Aug 10, 2025

Choose a reason for hiding this comment

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

I am not particularly happy with this giant match block.
There is a method that is perhaps meant to return the Attribute's Span, but it is not complete, and panics for many attributes. It would make sense for this match to move next to that span() method if this is the right approach at all.

@@ -1,33 +1,11 @@
error: use of a disallowed macro `serde::Serialize`
Copy link
Author

@2asoft 2asoft Aug 10, 2025

Choose a reason for hiding this comment

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

The order here changed. The new order is correct and matches the order that was here prior to a regression that introduced the bug that this PR fixes.
See my first comment on the linked issue for more details.

@2asoft 2asoft force-pushed the 2asoft/clippy_i14017 branch from 5b3451a to 50b3736 Compare August 10, 2025 17:37

// When a macro is disallowed in an early pass, it's stored
// and emitted during the late pass. This happens for attributes.
early_macro_cache: AttrStorage,
Copy link
Author

@2asoft 2asoft Aug 10, 2025

Choose a reason for hiding this comment

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

It is not clear to me what the plan is for AttrStorage and its usage in DisallowedMacros and elsewhere. Since it was introduced early in the attribute refactor, perhaps it was a temporary solution.

@jdonszelmann Could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.84.0 regression] #[allow(clippy::disallowed_macros)] does not work on two-argument std::panic
3 participants