about summary refs log tree commit diff
path: root/tests/rustdoc/attribute-rendering.rs
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-02 11:24:21 +0200
committerGitHub <noreply@github.com>2025-08-02 11:24:21 +0200
commit4eddebd42b87c688bb7ce8720b9da0d0e798f57a (patch)
tree0620957c1645f3a6910befe08ca64f24644d0c9a /tests/rustdoc/attribute-rendering.rs
parent93917ea97c1b5b98b30fae1f30a5f653dacfa7cf (diff)
parent45231fa599583edc95843aaa4f23b12f762e01e7 (diff)
downloadrust-4eddebd42b87c688bb7ce8720b9da0d0e798f57a.tar.gz
rust-4eddebd42b87c688bb7ce8720b9da0d0e798f57a.zip
Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdoc
[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.

Use Rust 2024 edition representation for unsafe attributes in rustdoc 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``````
Diffstat (limited to 'tests/rustdoc/attribute-rendering.rs')
-rw-r--r--tests/rustdoc/attribute-rendering.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/rustdoc/attribute-rendering.rs b/tests/rustdoc/attribute-rendering.rs
index 841533814c3..bf9b81077f3 100644
--- a/tests/rustdoc/attribute-rendering.rs
+++ b/tests/rustdoc/attribute-rendering.rs
@@ -1,7 +1,7 @@
 #![crate_name = "foo"]
 
 //@ has 'foo/fn.f.html'
-//@ has - //*[@'class="rust item-decl"]' '#[export_name = "f"] pub fn f()'
-#[export_name = "\
-f"]
+//@ has - //*[@'class="rust item-decl"]' '#[unsafe(export_name = "f")] pub fn f()'
+#[unsafe(export_name = "\
+f")]
 pub fn f() {}