Skip to content

[rustdoc] Display unsafe attrs with edition 2024 unsafe() wrappers. #143662

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

obi1kenobi
Copy link
Member

Use Rust 2024 edition representation for unsafe attributes in rustdoc JSON and HTML:

  • #[no_mangle] -> #[unsafe(no_mangle)]
  • #[export_name = "foo"] -> #[unsafe(export_name = "foo")]
  • #[link_section = ".text"] -> #[unsafe(link_section = ".text")]

The 2024 edition representation is used regardless of the crate's own edition. This ensures that Rustaceans don't have to learn the rules of an outdated edition (e.g. that unsafe() wasn't always necessary) in order to understand a crate's documentation.

After some looking through the T-rustdoc issues, I was not able to find an existing issue for this. Apologies if I missed it.

r? @aDotInTheVoid

@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2025

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

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 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

@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 9, 2025
@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Jul 9, 2025

#142936 is likely to merge before this, as this requires a FCP for UI changes. Therefore all the rustdoc-json changes are likely to go away here.

@rfcbot fcp merge

@obi1kenobi
Copy link
Member Author

Not an issue, thanks for the heads-up.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 9, 2025
@rust-lang rust-lang deleted a comment from rfcbot Jul 9, 2025
@aDotInTheVoid
Copy link
Member

@rfcbot fcp cancel

@rfcbot
Copy link
Collaborator

rfcbot commented Jul 9, 2025

@aDotInTheVoid proposal cancelled.

@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 9, 2025
@aDotInTheVoid aDotInTheVoid removed the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jul 9, 2025
@aDotInTheVoid
Copy link
Member

@rfcbot fcp merge

(accidentally FCP’d to full T-Rustdoc, not T-Rustdoc-Frontend 💀)

@aDotInTheVoid
Copy link
Member

@rust-lang/rustdoc-frontend can someone start an FCP on this?

@GuillaumeGomez
Copy link
Member

GuillaumeGomez commented Jul 9, 2025

Sounds like a good idea!

@aDotInTheVoid normally with only the t-rustdoc-frontend tag, you were good to go. 😉

EDIT: Ah no, just learned that you need o be part of the (sub-)team to do that, my bad.

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jul 9, 2025

Team member @GuillaumeGomez has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants