Skip to content

Commit 0e15b89

Browse files
committed
struct pattern: Add location on struct name
1 parent 425ebda commit 0e15b89

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

gcc/rust/ast/rust-pattern.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,18 +848,18 @@ class StructPattern : public Pattern
848848
// bool has_struct_pattern_elements;
849849
StructPatternElements elems;
850850

851-
// TODO: should this store location data? Accessor uses path location data.
852851
NodeId node_id;
852+
Location locus;
853853

854854
public:
855855
std::string as_string () const override;
856856

857857
// Constructs a struct pattern from specified StructPatternElements
858-
StructPattern (PathInExpression struct_path,
858+
StructPattern (PathInExpression struct_path, Location locus,
859859
StructPatternElements elems
860860
= StructPatternElements::create_empty ())
861861
: path (std::move (struct_path)), elems (std::move (elems)),
862-
node_id (Analysis::Mappings::get ()->get_next_node_id ())
862+
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
863863
{}
864864

865865
/* TODO: constructor to construct via elements included in

gcc/rust/parse/rust-parse-impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10603,7 +10603,8 @@ Parser<ManagedTokenSource>::parse_pattern ()
1060310603
}
1060410604

1060510605
return std::unique_ptr<AST::StructPattern> (
10606-
new AST::StructPattern (std::move (path), std::move (elems)));
10606+
new AST::StructPattern (std::move (path), t->get_locus (),
10607+
std::move (elems)));
1060710608
}
1060810609
default:
1060910610
// assume path in expression
@@ -11057,7 +11058,8 @@ Parser<ManagedTokenSource>::parse_ident_leading_pattern ()
1105711058
rust_debug ("successfully parsed struct pattern");
1105811059

1105911060
return std::unique_ptr<AST::StructPattern> (
11060-
new AST::StructPattern (std::move (path), std::move (elems)));
11061+
new AST::StructPattern (std::move (path), initial_tok->get_locus (),
11062+
std::move (elems)));
1106111063
}
1106211064
case DOT_DOT_EQ:
1106311065
case ELLIPSIS: {

0 commit comments

Comments
 (0)