Skip to content

Port #[macro_export] to the new attribute parsing infrastructure #143857

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

Periodic1911
Copy link
Contributor

Ports macro_export to the new attribute parsing infrastructure for #131229 (comment)

r? @oli-obk

cc @JonathanBrouwer @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@@ -26,12 +22,15 @@ macro_rules! d {
}

#[macro_export()]
//~^ ERROR malformed `macro_export` attribute input
Copy link
Contributor Author

@Periodic1911 Periodic1911 Jul 12, 2025

Choose a reason for hiding this comment

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

This is a breaking change! Malformed macro_export attributes have had a lint since 2023 (deny(invalid_macro_export_arguments)). This PR makes this an error.
Furthermore, #[macro_export()] has been accepted since 2023, and this PR makes that an error too.

As discussed in #142838 (comment), we can make breaking changes as long as we do a crater run. So this PR needs a crater run.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 13, 2025

☔ The latest upstream changes (presumably #140717) made this pull request unmergeable. Please resolve the merge conflicts.

@jdonszelmann
Copy link
Contributor

@Periodic1911 if you rebase I'll run a crater

@jdonszelmann jdonszelmann added T-lang Relevant to the language team I-lang-nominated Nominated for discussion during a lang team meeting. labels Jul 13, 2025
@jdonszelmann
Copy link
Contributor

@rust-lang/lang this makes a long-standing warning an error with a crater run. Just wanted to notify you

@traviscross traviscross added needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 13, 2025
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Jul 13, 2025
@jdonszelmann
Copy link
Contributor

@bors try

bors added a commit that referenced this pull request Jul 13, 2025
Port #[macro_export] to the new attribute parsing infrastructure

Ports macro_export to the new attribute parsing infrastructure for #131229 (comment)

r? `@oli-obk`

cc `@JonathanBrouwer` `@jdonszelmann`
@bors
Copy link
Collaborator

bors commented Jul 13, 2025

⌛ Trying commit ac1f122 with merge 723ab94...

@bors
Copy link
Collaborator

bors commented Jul 13, 2025

☀️ Try build successful - checks-actions
Build commit: 723ab94 (723ab942d877517caf445dafde0416803ef56501)

@jdonszelmann
Copy link
Contributor

@craterbot check

@jdonszelmann
Copy link
Contributor

@Periodic1911 FCP finished. if you rebase we can go for merge! :)

@oli-obk oli-obk assigned jdonszelmann and unassigned oli-obk Jul 28, 2025
@rustbot rustbot added T-clippy Relevant to the Clippy team. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jul 28, 2025
@@ -4187,8 +4187,13 @@ declare_lint! {
/// You can't have multiple arguments in a `#[macro_export(..)]`, or mention arguments other than `local_inner_macros`.
///
pub INVALID_MACRO_EXPORT_ARGUMENTS,
Warn,
Deny,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This lint is now deny by default and FCW

@Periodic1911
Copy link
Contributor Author

@jdonszelmann rebased! And I made some changes to the parser error handling in accordance with the lang team's decision. Did I comply exactly with what they had in mind?

@@ -0,0 +1,40 @@
Future incompatibility report: Future breakage diagnostic:
Copy link
Contributor Author

@Periodic1911 Periodic1911 Jul 28, 2025

Choose a reason for hiding this comment

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

Although the invalid_macro_export_argument.rs test passes (check-pass) with #![allow(invalid_macro_export_arguments)], it also prints FCWs to stderr

@rust-log-analyzer

This comment has been minimized.


fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let suggestions =
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "macro_export");
Copy link
Contributor

Choose a reason for hiding this comment

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

might be nice to only compute this when emitting the lint since that's quite uncommon. You could reduce deduplication by putting this code in a closure or macro.

@@ -213,7 +213,8 @@ extern crate wloop;
//~^ ERROR can't find crate for `wloop` [E0463]

#[macro_export = 18]
//~^ ERROR malformed `macro_export` attribute input
//~^ ERROR valid forms for the attribute are
//~| WARN this was previously accepted by the compiler
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this isn't very nice. It took me a while to see that this really was a problem, tried some things to make sure. But this was already an error, not a warning. Only the #[macro_export(meow)] was a warning that will become an error. For this form, the compiler already gave an error and now we're getting an error, plus also a warning that it'll be an error in the future. I don't think that's right

@bors
Copy link
Collaborator

bors commented Jul 31, 2025

☔ The latest upstream changes (presumably #144740) made this pull request unmergeable. Please resolve the merge conflicts.


fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let suggestions =
|| <Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "macro_export");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a closure now :)

//~^ ERROR malformed `macro_export` attribute input
//~^ ERROR valid forms for the attribute are
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You were right, this was always an error. I checked on stable, and the invalid_macro_export_arguments lint does not handle this

@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Aug 1, 2025

I expect the tests introduced by this PR to fail
#144700

@jdonszelmann
Copy link
Contributor

r=me after that, @bors delegate+

@bors
Copy link
Collaborator

bors commented Aug 1, 2025

✌️ @Periodic1911, you can now approve this pull request!

If @jdonszelmann told you to "r=me" after making some further change, please make that change, then do @bors r=@jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@Periodic1911
Copy link
Contributor Author

@bors r=@jdonszelmann

@bors
Copy link
Collaborator

bors commented Aug 1, 2025

📌 Commit 90fad60 has been approved by jdonszelmann

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-lang Relevant to the language team T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.