Skip to content

rustdoc drops #[no_mangle] and #[link_section] from inlined cross-crate re-exported fns & statics #144004

@fmease

Description

@fmease

Reproduction:

  • rustc a.rs --crate-type lib --edition 2024 a.rs where a.rs:
    #[unsafe(no_mangle)]
    pub fn f0() {}
    
    #[unsafe(link_section = ".here")]
    pub fn f1() {}
    
    #[unsafe(no_mangle)]
    pub static S0: () = ();
    
    #[unsafe(link_section = ".there")]
    pub static S1: () = ();
  • rustdoc b.rs --edition 2024 -L. --extern a where b.rs:
    pub use a::*;

Behavior:

  • On 1.88.0 (current stable), rustdoc doesn't render any of these attributes
  • On 1.89.0-beta.5 (current beta), rustdoc renders the #[no_mangle]s but not the #[link_section]s
  • On 1.90.0-nightly (3014e79 2025-07-15) (current master), rustdoc doesn't render any of these attributes yet again

The attributes #[repr], #[non_exhaustive] & #[export_name] are unaffected (i.e., the remaining allowlisted non-doc attrs).

Metadata

Metadata

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions