https://gcc.gnu.org/g:352f980360076a7bd4ed17d9eb0fb828ab08a3b9

commit r16-2903-g352f980360076a7bd4ed17d9eb0fb828ab08a3b9
Author: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>
Date:   Fri Jun 27 13:31:17 2025 +0200

    gccrs: Add locus getters
    
    gcc/rust/ChangeLog:
    
            * ast/rust-expr.h: Add getter to locus field.
            * ast/rust-pattern.h (tokenid_to_rangekind): Likewise.
            * hir/tree/rust-hir-item.h: Likewise.
            * hir/tree/rust-hir-visibility.h: Likewise.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>

Diff:
---
 gcc/rust/ast/rust-expr.h                | 6 ++++++
 gcc/rust/ast/rust-pattern.h             | 2 +-
 gcc/rust/hir/tree/rust-hir-item.h       | 2 ++
 gcc/rust/hir/tree/rust-hir-visibility.h | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 8f44d5878bbf..21e856bb1d0e 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -1192,6 +1192,8 @@ public:
 
   std::string as_string () const override;
 
+  location_t get_locus () const { return locus; }
+
   void accept_vis (ASTVisitor &vis) override;
 
   // TODO: this mutable getter seems really dodgy. Think up better way.
@@ -1248,6 +1250,8 @@ public:
 
   std::string as_string () const override;
 
+  location_t get_locus () const { return locus; }
+
   void accept_vis (ASTVisitor &vis) override;
 
   // TODO: is this better? Or is a "vis_block" better?
@@ -1777,6 +1781,8 @@ public:
 
   std::string as_string () const;
 
+  location_t get_locus () const { return locus; }
+
   // TODO: is this better? Or is a "vis_block" better?
   Expr &get_base_struct ()
   {
diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h
index b9c0fd9bb2f1..57c065ff6955 100644
--- a/gcc/rust/ast/rust-pattern.h
+++ b/gcc/rust/ast/rust-pattern.h
@@ -948,7 +948,7 @@ public:
    * is empty). */
   bool has_struct_pattern_elems () const { return !elems.is_empty (); }
 
-  location_t get_locus () const override { return path.get_locus (); }
+  location_t get_locus () const override { return locus; }
 
   void accept_vis (ASTVisitor &vis) override;
 
diff --git a/gcc/rust/hir/tree/rust-hir-item.h 
b/gcc/rust/hir/tree/rust-hir-item.h
index 8cedfe8647dc..d9df6029c5ac 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -209,6 +209,8 @@ public:
 
   std::string as_string () const override;
 
+  location_t get_locus () const { return locus; }
+
   void accept_vis (HIRFullVisitor &vis) override;
 
   Lifetime &get_lifetime () { return lifetime; }
diff --git a/gcc/rust/hir/tree/rust-hir-visibility.h 
b/gcc/rust/hir/tree/rust-hir-visibility.h
index a750d88f284d..9dd6ff292674 100644
--- a/gcc/rust/hir/tree/rust-hir-visibility.h
+++ b/gcc/rust/hir/tree/rust-hir-visibility.h
@@ -73,6 +73,8 @@ public:
   }
 
   std::string as_string () const;
+
+  location_t get_locus () const { return locus; }
 };
 } // namespace HIR
 } // namespace Rust

Reply via email to