From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id E18173817D04; Wed, 8 Jun 2022 12:08:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E18173817D04 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] struct pattern: Add location on struct name X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 425ebda24393eb4f40190228b7ef4b69e6253251 X-Git-Newrev: 0e15b89839170cb6c9115cfc57310af2170423a0 Message-Id: <20220608120850.E18173817D04@sourceware.org> Date: Wed, 8 Jun 2022 12:08:50 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:08:51 -0000 https://gcc.gnu.org/g:0e15b89839170cb6c9115cfc57310af2170423a0 commit 0e15b89839170cb6c9115cfc57310af2170423a0 Author: Arthur Cohen 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::parse_pattern () } return std::unique_ptr ( - 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::parse_ident_leading_pattern () rust_debug ("successfully parsed struct pattern"); return std::unique_ptr ( - 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: {