Thanks to visit codestin.com
Credit goes to github.com

Skip to content

empty_struct_with_brackets: do not lint code coming from macro expansion #14623

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 1 commit into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Contributor

Do not attempt to fetch a snippet from expansion. Without this change, the inside of macros could[*] be shown as the source of the problem.

[*] Due to the way the source code is processed and reparsed in this macro, the declarative macro has to be located outside the current source file for the bug to appear. Otherwise, the macro call itself will be (mis)identified as a potential struct field definition and the lint will not trigger.

changelog: [empty_struct_with_brackets]: do not lint code coming from macro expansion

@rustbot
Copy link
Collaborator

rustbot commented Apr 15, 2025

r? @y21

rustbot has assigned @y21.
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 Apr 15, 2025

#[macro_export]
macro_rules! empty_struct {
($i:ident) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason this takes an ident? It seems unused in the macro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was an oversight. Moreover, it doesn't require using an aux-build here. Fixed.

Do not attempt to fetch a snippet from expansion. Without this change,
the inside of macros could[*] be shown as the source of the problem.

[*] Due to the way the source code is processed and reparsed in this
macro, the declarative macro has to be located outside the current
source file for the bug to appear. Otherwise, the macro call itself
will be (mis)identified as a potential `struct` field definition and the
lint will not trigger.
@samueltardieu samueltardieu force-pushed the empty-struct-with-brackets-snippet branch from 4067b99 to 4de5b27 Compare May 5, 2025 21:20
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.

3 participants