[gcc r14-7665] gccrs: expand: Make to_derive argument const

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 17:51:54 GMT 2024


https://gcc.gnu.org/g:d41160ca9747e085e28130c38ec04804082a45e2

commit r14-7665-gd41160ca9747e085e28130c38ec04804082a45e2
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Jun 7 12:43:07 2023 +0200

    gccrs: expand: Make to_derive argument const
    
    This string will never change and can be constified.
    
    gcc/rust/ChangeLog:
    
            * expand/rust-expand-visitor.cc (derive_item): Add const
            attribute to the trait name argument.
            * expand/rust-macro-expand.h (struct MacroExpander): Likewise.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/expand/rust-expand-visitor.cc | 2 +-
 gcc/rust/expand/rust-macro-expand.h    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index c7a5f573d7e..3601287be99 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -104,7 +104,7 @@ builtin_derive_item (std::unique_ptr<AST::Item> &item,
 }
 
 static std::vector<std::unique_ptr<AST::Item>>
-derive_item (std::unique_ptr<AST::Item> &item, std::string &to_derive,
+derive_item (std::unique_ptr<AST::Item> &item, const std::string &to_derive,
 	     MacroExpander &expander)
 {
   std::vector<std::unique_ptr<AST::Item>> result;
diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h
index 0e53913438a..8ac84d513b2 100644
--- a/gcc/rust/expand/rust-macro-expand.h
+++ b/gcc/rust/expand/rust-macro-expand.h
@@ -340,7 +340,8 @@ struct MacroExpander
   void import_proc_macros (std::string extern_crate);
 
   template <typename T>
-  AST::Fragment expand_derive_proc_macro (T &item, std::string &trait_name)
+  AST::Fragment expand_derive_proc_macro (T &item,
+					  const std::string &trait_name)
   {
     ProcMacro::CustomDerive macro;


More information about the Gcc-cvs mailing list