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

https://gcc.gnu.org/g:0e15b89839170cb6c9115cfc57310af2170423a0

commit 0e15b89839170cb6c9115cfc57310af2170423a0
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Thu Feb 17 16:36:34 2022 +0100

    struct pattern: Add location on struct name

Diff:
---
 gcc/rust/ast/rust-pattern.h      | 6 +++---
 gcc/rust/parse/rust-parse-impl.h | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h
index 3b8dbd73ffe..5d937d73925 100644
--- a/gcc/rust/ast/rust-pattern.h
+++ b/gcc/rust/ast/rust-pattern.h
@@ -848,18 +848,18 @@ class StructPattern : public Pattern
   // bool has_struct_pattern_elements;
   StructPatternElements elems;
 
-  // TODO: should this store location data? Accessor uses path location data.
   NodeId node_id;
+  Location locus;
 
 public:
   std::string as_string () const override;
 
   // Constructs a struct pattern from specified StructPatternElements
-  StructPattern (PathInExpression struct_path,
+  StructPattern (PathInExpression struct_path, Location locus,
 		 StructPatternElements elems
 		 = StructPatternElements::create_empty ())
     : path (std::move (struct_path)), elems (std::move (elems)),
-      node_id (Analysis::Mappings::get ()->get_next_node_id ())
+      node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
   {}
 
   /* TODO: constructor to construct via elements included in
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index c35595c29d7..2260a9509e5 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -10603,7 +10603,8 @@ Parser<ManagedTokenSource>::parse_pattern ()
 		}
 
 	      return std::unique_ptr<AST::StructPattern> (
-		new AST::StructPattern (std::move (path), std::move (elems)));
+		new AST::StructPattern (std::move (path), t->get_locus (),
+					std::move (elems)));
 	    }
 	  default:
 	    // assume path in expression
@@ -11057,7 +11058,8 @@ Parser<ManagedTokenSource>::parse_ident_leading_pattern ()
 	rust_debug ("successfully parsed struct pattern");
 
 	return std::unique_ptr<AST::StructPattern> (
-	  new AST::StructPattern (std::move (path), std::move (elems)));
+	  new AST::StructPattern (std::move (path), initial_tok->get_locus (),
+				  std::move (elems)));
       }
     case DOT_DOT_EQ:
       case ELLIPSIS: {


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

only message in thread, other threads:[~2022-06-08 12:08 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:08 [gcc/devel/rust/master] struct pattern: Add location on struct name 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).