[COMMITTED 45/77] gccrs: rust: Add const getter overloads for HIR pattern fields

[email protected]
Newsgroups gmane.comp.gcc.rust,gmane.comp.gcc.patches
Message-ID <[email protected]>
From: Egas Ribeiro <[email protected]>

These const overloads are needed by the type-aware refutability check in
HIR pattern nodes, which accesses pattern fields through const
references.

	Addresses: Rust-GCC#2082

gcc/rust/ChangeLog:

	* hir/tree/rust-hir-pattern.h: Add const overloads.

Co-authored-by: João Novo <[email protected]>
Signed-off-by: Egas Ribeiro <[email protected]>
---
 gcc/rust/hir/tree/rust-hir-pattern.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h
index c5997c11d6f..bc9c63fae0a 100644
--- a/gcc/rust/hir/tree/rust-hir-pattern.h
+++ b/gcc/rust/hir/tree/rust-hir-pattern.h
@@ -586,8 +586,13 @@ public:
   void accept_vis (HIRFullVisitor &vis) override;
 
   TupleIndex get_index () { return index; }
+
+  TupleIndex get_index () const { return index; }
+
   Pattern &get_tuple_pattern () { return *tuple_pattern; }
 
+  const Pattern &get_tuple_pattern () const { return *tuple_pattern; }
+
   ItemType get_item_type () const override final { return ItemType::TUPLE_PAT; }
 
 protected:
@@ -645,6 +650,7 @@ public:
   Identifier get_identifier () const { return ident; }
 
   Pattern &get_pattern () { return *ident_pattern; }
+  Pattern &get_pattern () const { return *ident_pattern; }
 
 protected:
   /* Use covariance to implement clone function as returning this object rather
@@ -754,6 +760,12 @@ public:
   {
     return fields;
   }
+
+  const std::vector<std::unique_ptr<StructPatternField>> &
+  get_struct_pattern_fields () const
+  {
+    return fields;
+  }
 };
 
 // Struct pattern HIR node representation
-- 
2.50.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.