https://gcc.gnu.org/g:6068e7aac646703fb563785b6d93f913180970a9

commit 6068e7aac646703fb563785b6d93f913180970a9
Author: Arthur Cohen <arthur.co...@embecosm.com>
Date:   Wed Apr 9 15:17:38 2025 +0200

    attributes: Handle external tool annotations like rustfmt::
    
    gcc/rust/ChangeLog:
    
            * util/rust-attribute-values.h: Add RUSTFMT value.
            * util/rust-attributes.cc: Define the attribute.
            * util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant.
            * expand/rust-macro-builtins.cc: Fix formatting.

Diff:
---
 gcc/rust/expand/rust-macro-builtins.cc | 1 -
 gcc/rust/util/rust-attribute-values.h  | 2 ++
 gcc/rust/util/rust-attributes.cc       | 3 ++-
 gcc/rust/util/rust-attributes.h        | 5 ++++-
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/expand/rust-macro-builtins.cc 
b/gcc/rust/expand/rust-macro-builtins.cc
index d5b6dec4a71f..d8013c108515 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -83,7 +83,6 @@ const BiMap<std::string, BuiltinMacro> MacroBuiltin::builtins 
= {{
   {"Ord", BuiltinMacro::Ord},
   {"PartialOrd", BuiltinMacro::PartialOrd},
   {"Hash", BuiltinMacro::Hash},
-
 }};
 
 AST::MacroTranscriberFunc
diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index 1d69b7af239b..6e0aa48b26f5 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -83,6 +83,8 @@ public:
   static constexpr auto &FUNDAMENTAL = "fundamental";
 
   static constexpr auto &NON_EXHAUSTIVE = "non_exhaustive";
+
+  static constexpr auto &RUSTFMT = "rustfmt";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 0442ff1d5258..2c1bd195b528 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -94,7 +94,8 @@ static const BuiltinAttrDefinition __definitions[]
      {Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
 
      {Attrs::FUNDAMENTAL, TYPE_CHECK},
-     {Attrs::NON_EXHAUSTIVE, TYPE_CHECK}};
+     {Attrs::NON_EXHAUSTIVE, TYPE_CHECK},
+     {Attrs::RUSTFMT, EXTERNAL}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index e7e50835f58c..16e4847da99e 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -40,7 +40,10 @@ enum CompilerPass
   HIR_LOWERING,
   TYPE_CHECK,
   STATIC_ANALYSIS,
-  CODE_GENERATION
+  CODE_GENERATION,
+
+  // External Rust tooling attributes, like #[rustfmt::skip]
+  EXTERNAL,
 
   // Do we need to add something here for const fns?
 };

Reply via email to