public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] resolve: Resolve range patterns
Date: Wed,  8 Jun 2022 12:47:06 +0000 (GMT)	[thread overview]
Message-ID: <20220608124706.B15EC380E182@sourceware.org> (raw)

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) {}
 };


                 reply	other threads:[~2022-06-08 12:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608124706.B15EC380E182@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).