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]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/cc9260f616302882b0330665bf2d2fc247bcf289
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4571
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 c5997c11d..bc9c63fae 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
base-commit: dc865d949654a0f181c55e3eeaac5d57a7a9f16f
--
2.54.0