Skip to content
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

macro_use_import: Don't check is attribute comes from expansion #14317

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

flip1995
Copy link
Member

It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the check_item will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
check_attribute function, and with that the problematic attr.span() call can
be completely removed.

Fixes #14303

r? @y21

cc @jdonszelmann

changelog: Fix ICE in [macro_use_import] lint

It is not possible to write a declarative macro, that produces an attribute w/o
an item attached to it. This means that the `check_item` will already insert the
span in the map, if it came from an expansion. So additionally checking if the
macro came from an expansion doesn't add anything here. So the
`check_attribute` function, and with that the problematic `attr.span()` call can
be completely removed.

Fixes rust-lang#14303
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 27, 2025
@flip1995
Copy link
Member Author

On our current master this doesn't ICE, as we're still on an earlier nightly. However I tested this commit on top of #14300 and verified that it actually fixes it.

After this is merged, I will do a Clippy->Rust sync to get it into nightly ASAP.

@jdonszelmann
Copy link
Contributor

Seems like a trivial fix, nothing wrong with it :) I'd r+ if I could haha

@Centri3 Centri3 added this pull request to the merge queue Feb 27, 2025
Merged via the queue into rust-lang:master with commit 15180d4 Feb 27, 2025
11 checks passed
@flip1995 flip1995 deleted the ice-14303 branch February 27, 2025 20:53
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.

macro_use_imports ICE: can't get the span of an arbitrary parsed attribute: ...
5 participants