From: Owen Avery <powerboat9.ga...@gmail.com>

gcc/rust/ChangeLog:

        * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Add proper 
visitor.
        * hir/rust-ast-lower-pattern.h: Declare it.

Signed-off-by: Owen Avery <powerboat9.ga...@gmail.com>
---
 gcc/rust/hir/rust-ast-lower-pattern.cc | 16 ++++++++++++++++
 gcc/rust/hir/rust-ast-lower-pattern.h  |  1 +
 2 files changed, 17 insertions(+)

diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc 
b/gcc/rust/hir/rust-ast-lower-pattern.cc
index 30a188286c8..8ee3a979a33 100644
--- a/gcc/rust/hir/rust-ast-lower-pattern.cc
+++ b/gcc/rust/hir/rust-ast-lower-pattern.cc
@@ -243,5 +243,21 @@ ASTLoweringPattern::visit (AST::RangePattern &pattern)
                             std::move (upper_bound), pattern.get_locus ());
 }
 
+void
+ASTLoweringPattern::visit (AST::GroupedPattern &pattern)
+{
+  auto crate_num = mappings->get_current_crate ();
+  Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
+                                mappings->get_next_hir_id (crate_num),
+                                UNKNOWN_LOCAL_DEFID);
+
+  HIR::Pattern *inner
+    = ASTLoweringPattern::translate (pattern.get_pattern_in_parens ().get ());
+
+  translated
+    = new HIR::GroupedPattern (mapping, std::unique_ptr<HIR::Pattern> (inner),
+                              pattern.get_locus ());
+}
+
 } // namespace HIR
 } // namespace Rust
diff --git a/gcc/rust/hir/rust-ast-lower-pattern.h 
b/gcc/rust/hir/rust-ast-lower-pattern.h
index 8b191d56868..0075e27e9c0 100644
--- a/gcc/rust/hir/rust-ast-lower-pattern.h
+++ b/gcc/rust/hir/rust-ast-lower-pattern.h
@@ -39,6 +39,7 @@ public:
   void visit (AST::TuplePattern &pattern) override;
   void visit (AST::LiteralPattern &pattern) override;
   void visit (AST::RangePattern &pattern) override;
+  void visit (AST::GroupedPattern &pattern) override;
 
 private:
   ASTLoweringPattern ();
-- 
2.40.0

Reply via email to