@@ -4118,12 +4118,14 @@ AttributeParser::parse_meta_item_inner ()
4118
4118
return parse_path_meta_item ();
4119
4119
}
4120
4120
4121
- Identifier ident = peek_token ()-> as_string ();
4121
+ auto &identifier = peek_token ();
4122
4122
if (is_end_meta_item_tok (peek_token (1 )->get_id ()))
4123
4123
{
4124
4124
// meta word syntax
4125
4125
skip_token ();
4126
- return std::unique_ptr<MetaWord> (new MetaWord (std::move (ident)));
4126
+ // FIXME: We probably need a Location here as well
4127
+ return std::unique_ptr<MetaWord> (
4128
+ new MetaWord (identifier->as_string ()));
4127
4129
}
4128
4130
4129
4131
if (peek_token (1 )->get_id () == EQUAL)
@@ -4133,15 +4135,19 @@ AttributeParser::parse_meta_item_inner ()
4133
4135
&& is_end_meta_item_tok (peek_token (3 )->get_id ()))
4134
4136
{
4135
4137
// meta name value str syntax
4136
- std::string value = peek_token (2 )->as_string ();
4138
+ auto &value_tok = peek_token (2 );
4139
+ auto value = value_tok->as_string ();
4140
+ auto locus = value_tok->get_locus ();
4137
4141
4138
4142
skip_token (2 );
4139
4143
4140
4144
// remove the quotes from the string value
4141
4145
std::string raw_value = unquote_string (std::move (value));
4142
4146
4143
4147
return std::unique_ptr<MetaNameValueStr> (
4144
- new MetaNameValueStr (std::move (ident), std::move (raw_value)));
4148
+ new MetaNameValueStr (identifier->as_string (),
4149
+ identifier->get_locus (),
4150
+ std::move (raw_value), locus));
4145
4151
}
4146
4152
else
4147
4153
{
@@ -4183,7 +4189,7 @@ AttributeParser::parse_meta_item_inner ()
4183
4189
if (!meta_name_value_str_items.empty ())
4184
4190
{
4185
4191
return std::unique_ptr<MetaListNameValueStr> (
4186
- new MetaListNameValueStr (std::move (ident ),
4192
+ new MetaListNameValueStr (identifier-> as_string ( ),
4187
4193
std::move (meta_name_value_str_items)));
4188
4194
}
4189
4195
@@ -4222,7 +4228,7 @@ AttributeParser::parse_meta_item_inner ()
4222
4228
if (!path_items.empty ())
4223
4229
{
4224
4230
return std::unique_ptr<MetaListPaths> (
4225
- new MetaListPaths (std::move (ident ), std::move (path_items)));
4231
+ new MetaListPaths (identifier-> as_string ( ), std::move (path_items)));
4226
4232
}
4227
4233
4228
4234
rust_error_at (Linemap::unknown_location (),
@@ -4694,11 +4700,11 @@ Attribute
4694
4700
MetaNameValueStr::to_attribute () const
4695
4701
{
4696
4702
LiteralExpr lit_expr (str, Literal::LitType::STRING,
4697
- PrimitiveCoreType::CORETYPE_UNKNOWN, {}, Location () );
4703
+ PrimitiveCoreType::CORETYPE_UNKNOWN, {}, str_locus );
4698
4704
// FIXME: What location do we put here? Is the literal above supposed to have
4699
4705
// an empty location as well?
4700
4706
// Should MetaNameValueStr keep a location?
4701
- return Attribute (SimplePath::from_str (ident, Location () ),
4707
+ return Attribute (SimplePath::from_str (ident, ident_locus ),
4702
4708
std::unique_ptr<AttrInputLiteral> (
4703
4709
new AttrInputLiteral (std::move (lit_expr))));
4704
4710
}
0 commit comments