Skip to content

Commit ffb38df

Browse files
committed
ast: Add location info to MetaWord
1 parent 34c73a7 commit ffb38df

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

gcc/rust/ast/rust-ast-full-test.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4125,7 +4125,7 @@ AttributeParser::parse_meta_item_inner ()
41254125
skip_token ();
41264126
// FIXME: We probably need a Location here as well
41274127
return std::unique_ptr<MetaWord> (
4128-
new MetaWord (identifier->as_string ()));
4128+
new MetaWord (identifier->as_string (), identifier->get_locus ()));
41294129
}
41304130

41314131
if (peek_token (1)->get_id () == EQUAL)
@@ -4731,8 +4731,7 @@ MetaItemSeq::to_attribute () const
47314731
Attribute
47324732
MetaWord::to_attribute () const
47334733
{
4734-
// FIXME: How do we get a location here?
4735-
return Attribute (SimplePath::from_str (ident, Location ()), nullptr);
4734+
return Attribute (SimplePath::from_str (ident, ident_locus), nullptr);
47364735
}
47374736

47384737
Attribute

gcc/rust/ast/rust-macro.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,12 @@ class MetaItemSeq : public MetaItem
759759
class MetaWord : public MetaItem
760760
{
761761
Identifier ident;
762+
Location ident_locus;
762763

763764
public:
764-
MetaWord (Identifier ident) : ident (std::move (ident)) {}
765+
MetaWord (Identifier ident, Location ident_locus)
766+
: ident (std::move (ident)), ident_locus (ident_locus)
767+
{}
765768

766769
std::string as_string () const override { return ident; }
767770

0 commit comments

Comments
 (0)