Port #[export_name] to the new attribute parsing infrastructure

Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
This commit is contained in:
Jonathan Brouwer 2025-06-24 22:33:44 +02:00
parent bc4376fa73
commit 287d9afce7
No known key found for this signature in database
GPG key ID: F13E55D38C971DEF
13 changed files with 84 additions and 46 deletions

View file

@ -755,8 +755,11 @@ impl Item {
.filter_map(|attr| {
// NoMangle is special cased, as it appears in HTML output, and we want to show it in source form, not HIR printing.
// It is also used by cargo-semver-checks.
if matches!(attr, hir::Attribute::Parsed(AttributeKind::NoMangle(..))) {
if let hir::Attribute::Parsed(AttributeKind::NoMangle(..)) = attr {
Some("#[no_mangle]".to_string())
} else if let hir::Attribute::Parsed(AttributeKind::ExportName { name, .. }) = attr
{
Some(format!("#[export_name = \"{name}\"]"))
} else if is_json {
match attr {
// rustdoc-json stores this in `Item::deprecation`, so we