Skip to content

Port #[no_mangle] to new attribute parsing infrastructure #142823

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

JonathanBrouwer
Copy link
Contributor

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

r? @jdonszelmann

@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@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. labels Jun 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

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

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

|
LL | #[no_mangle]
| ^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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 warning is new, but I think this is reasonable in this context.
Is adding this warning acceptable?

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 21, 2025
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Jun 21, 2025
@JonathanBrouwer
Copy link
Contributor Author

Woops I accidentally rebased on the wrong commit and git did not like that, should be good now :P

@rust-log-analyzer

This comment has been minimized.

@jdonszelmann
Copy link
Contributor

r=me after that and ci

@jdonszelmann
Copy link
Contributor

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Jun 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi

These commits modify tests/rustdoc-json.
rustdoc-json is a public (but unstable) interface.

Please ensure that if you've changed the output:

  • It's intentional.
  • The FORMAT_VERSION in src/librustdoc-json-types is bumped if necessary.

cc @aDotInTheVoid, @obi1kenobi

@JonathanBrouwer JonathanBrouwer force-pushed the no_mangle_parser branch 2 times, most recently from 71e01ef to 06e2148 Compare June 21, 2025 13:59
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@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 Jun 21, 2025
@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer force-pushed the no_mangle_parser branch 2 times, most recently from 88fc125 to 5afce2b Compare June 21, 2025 16:14
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jun 21, 2025

@rustbot ready
All problems mentioned above are resolved other than the "adding the new warning" thing and CI should pass now? (I hope I don't jinx this)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 21, 2025
@@ -1,6 +1,6 @@
//@ edition: 2021
#![no_std]

//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]'
//@ is "$.index[?(@.name=='example')].attrs" '["#[attr = NoMangle]"]'
Copy link
Member

Choose a reason for hiding this comment

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

I believe the code changes reverted the pretty-print output here, so this test change might not be necessary anymore and might need to be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the code changes only apply to rustdoc, there's a separate if statement earlier in that function for rustdoc-json.

Not sure if the seperate formatting between the two is ideal tho, would be nice to keep that consistent

Copy link
Member

Choose a reason for hiding this comment

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

For rustdoc JSON it would be strongly preferable to have #[no_mangle] because the alternative will break cargo-semver-checks. The consistency argument is also very good.

So I'm in favor of making the change here if at all possible, and in a separate PR otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make the change in this PR, will do it tomorrow

Copy link
Member

Choose a reason for hiding this comment

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

Thank you, I really appreciate it — it will make my cargo-semver-checks work a lot easier!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your work btw, love the tool!

Copy link
Member

Choose a reason for hiding this comment

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

Thank you, that made my day!

@@ -4,6 +4,6 @@
// The representation of `#[unsafe(no_mangle)]` in rustdoc in edition 2024
// is still `#[no_mangle]` without the `unsafe` attribute wrapper.

//@ is "$.index[?(@.name=='example')].attrs" '["#[no_mangle]"]'
//@ is "$.index[?(@.name=='example')].attrs" '["#[attr = NoMangle]"]'
Copy link
Member

Choose a reason for hiding this comment

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

Same with this change.

@JonathanBrouwer
Copy link
Contributor Author

@rustbot author
I'll revert the change to the warning until tlang reaches a consensus and I'll fix the rustdoc problems

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 21, 2025
@bors
Copy link
Collaborator

bors commented Jun 21, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants