public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] resolve: Resolve range patterns
@ 2022-06-08 12:47 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:26c832fcc2e344c222c6d6ca5cdb613b003aebf9

commit 26c832fcc2e344c222c6d6ca5cdb613b003aebf9
Author: David Faust <david.faust@oracle.com>
Date:   Thu May 12 15:47:34 2022 -0700

    resolve: Resolve range patterns

Diff:
---
 gcc/rust/resolve/rust-ast-resolve-pattern.cc | 34 ++++++++++++++++++++++++++++
 gcc/rust/resolve/rust-ast-resolve-pattern.h  |  2 ++
 2 files changed, 36 insertions(+)

diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.cc b/gcc/rust/resolve/rust-ast-resolve-pattern.cc
index bac55212f48..dc2cca41fef 100644
--- a/gcc/rust/resolve/rust-ast-resolve-pattern.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-pattern.cc
@@ -131,5 +131,39 @@ PatternDeclaration::visit (AST::TuplePattern &pattern)
     }
 }
 
+static void
+resolve_range_pattern_bound (AST::RangePatternBound *bound, NodeId parent)
+{
+  switch (bound->get_bound_type ())
+    {
+    case AST::RangePatternBound::RangePatternBoundType::LITERAL:
+      // Nothing to resolve for a literal.
+      break;
+
+      case AST::RangePatternBound::RangePatternBoundType::PATH: {
+	AST::RangePatternBoundPath &ref
+	  = *static_cast<AST::RangePatternBoundPath *> (bound);
+
+	ResolvePath::go (&ref.get_path (), parent);
+      }
+      break;
+
+      case AST::RangePatternBound::RangePatternBoundType::QUALPATH: {
+	AST::RangePatternBoundQualPath &ref
+	  = *static_cast<AST::RangePatternBoundQualPath *> (bound);
+
+	ResolvePath::go (&ref.get_qualified_path (), parent);
+      }
+      break;
+    }
+}
+
+void
+PatternDeclaration::visit (AST::RangePattern &pattern)
+{
+  resolve_range_pattern_bound (pattern.get_upper_bound ().get (), parent);
+  resolve_range_pattern_bound (pattern.get_lower_bound ().get (), parent);
+}
+
 } // namespace Resolver
 } // namespace Rust
diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.h b/gcc/rust/resolve/rust-ast-resolve-pattern.h
index 464e3628768..dfb05d3a4af 100644
--- a/gcc/rust/resolve/rust-ast-resolve-pattern.h
+++ b/gcc/rust/resolve/rust-ast-resolve-pattern.h
@@ -103,6 +103,8 @@ public:
 
   void visit (AST::TuplePattern &pattern) override;
 
+  void visit (AST::RangePattern &pattern) override;
+
 private:
   PatternDeclaration (NodeId parent) : ResolverBase (parent) {}
 };


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:47 [gcc/devel/rust/master] resolve: Resolve range patterns Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).