From 49ae52e3ffeb3d98f19845eba5eb9fa1408fa432 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Thu, 17 Jul 2025 08:02:26 +0200 Subject: [PATCH 1/2] Fix encoding of `link_section` and `no_mangle` cross crate --- .../rustc_attr_data_structures/src/encode_cross_crate.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs b/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs index 3e2dc0a15b2f3..c24b45e83f907 100644 --- a/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs +++ b/compiler/rustc_attr_data_structures/src/encode_cross_crate.rs @@ -40,9 +40,9 @@ impl AttributeKind { Fundamental { .. } => Yes, Ignore { .. } => No, Inline(..) => No, - LinkName { .. } => Yes, + LinkName { .. } => Yes, // Needed for rustdoc LinkOrdinal { .. } => No, - LinkSection { .. } => No, + LinkSection { .. } => Yes, // Needed for rustdoc LoopMatch(..) => No, MacroTransparency(..) => Yes, Marker(..) => No, @@ -50,8 +50,8 @@ impl AttributeKind { MustUse { .. } => Yes, Naked(..) => No, NoImplicitPrelude(..) => No, - NoMangle(..) => No, - NonExhaustive(..) => Yes, + NoMangle(..) => Yes, // Needed for rustdoc + NonExhaustive(..) => Yes, // Needed for rustdoc OmitGdbPrettyPrinterSection => No, Optimize(..) => No, ParenSugar(..) => No, From 9f16db6611b0fb35f4a16dcbf326fb9aee3d87f3 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Thu, 17 Jul 2025 08:03:17 +0200 Subject: [PATCH 2/2] Regression test --- .../reexport/auxiliary/reexports-attrs.rs | 14 +++++++++++++ tests/rustdoc/reexport/reexport-attrs.rs | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/rustdoc/reexport/auxiliary/reexports-attrs.rs create mode 100644 tests/rustdoc/reexport/reexport-attrs.rs diff --git a/tests/rustdoc/reexport/auxiliary/reexports-attrs.rs b/tests/rustdoc/reexport/auxiliary/reexports-attrs.rs new file mode 100644 index 0000000000000..96fa8209cde84 --- /dev/null +++ b/tests/rustdoc/reexport/auxiliary/reexports-attrs.rs @@ -0,0 +1,14 @@ +#[unsafe(no_mangle)] +pub fn f0() {} + +#[unsafe(link_section = ".here")] +pub fn f1() {} + +#[unsafe(export_name = "f2export")] +pub fn f2() {} + +#[repr(u8)] +pub enum T0 { V1 } + +#[non_exhaustive] +pub enum T1 {} diff --git a/tests/rustdoc/reexport/reexport-attrs.rs b/tests/rustdoc/reexport/reexport-attrs.rs new file mode 100644 index 0000000000000..0ec645841f0b8 --- /dev/null +++ b/tests/rustdoc/reexport/reexport-attrs.rs @@ -0,0 +1,20 @@ +//@ aux-build: reexports-attrs.rs + +#![crate_name = "foo"] + +extern crate reexports_attrs; + +//@ has 'foo/fn.f0.html' '//pre[@class="rust item-decl"]' '#[no_mangle]' +pub use reexports_attrs::f0; + +//@ has 'foo/fn.f1.html' '//pre[@class="rust item-decl"]' '#[link_section = ".here"]' +pub use reexports_attrs::f1; + +//@ has 'foo/fn.f2.html' '//pre[@class="rust item-decl"]' '#[export_name = "f2export"]' +pub use reexports_attrs::f2; + +//@ has 'foo/enum.T0.html' '//pre[@class="rust item-decl"]' '#[repr(u8)]' +pub use reexports_attrs::T0; + +//@ has 'foo/enum.T1.html' '//pre[@class="rust item-decl"]' '#[non_exhaustive]' +pub use reexports_attrs::T1;