about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-06-26 20:15:23 -0400
committerGitHub <noreply@github.com>2025-06-26 20:15:23 -0400
commitd3866007fa30fd3ae3c5ba09299d731b9080bbad (patch)
tree6d4b074055ad5e09d96c94f3fbca7e259046765e /src
parentc5ac143b2272d598e6608b3f44b19d3a31b0a5ad (diff)
parent3d1cee53244dce3a9e58e04c87ba8d02d964f79f (diff)
downloadrust-d3866007fa30fd3ae3c5ba09299d731b9080bbad.tar.gz
rust-d3866007fa30fd3ae3c5ba09299d731b9080bbad.zip
Rollup merge of #142986 - JonathanBrouwer:export_name_parser, r=jdonszelmann
Port `#[export_name]` to the new attribute parsing infrastructure

This PR contains two changes, in separate commits for reviewability:
- Ports `export_name` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197
- Moves the check for mixing export_name/no_mangle to check_attr.rs and improve the error message, which previously had a mix of 2021/2024 edition syntax

r? ``@jdonszelmann``
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/clean/types.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 69899539b45..3cac55493f0 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -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