@@ -288,7 +288,7 @@ Attribute::get_traits_to_derive ()
288
288
break ;
289
289
case AST::MetaItem::ItemKind::ListPaths:
290
290
case AST::MetaItem::ItemKind::NameValueStr:
291
- case AST::MetaItem::ItemKind::PathLit :
291
+ case AST::MetaItem::ItemKind::PathExpr :
292
292
case AST::MetaItem::ItemKind::Seq:
293
293
case AST::MetaItem::ItemKind::ListNameValueStr:
294
294
default :
@@ -3712,20 +3712,12 @@ AttributeParser::parse_path_meta_item ()
3712
3712
{
3713
3713
skip_token ();
3714
3714
3715
- location_t locus = peek_token ()->get_locus ();
3716
- Literal lit = parse_literal ();
3717
- if (lit.is_error ())
3718
- {
3719
- rust_error_at (peek_token ()->get_locus (),
3720
- " failed to parse literal in attribute" );
3721
- return nullptr ;
3722
- }
3723
- LiteralExpr expr (std::move (lit), {}, locus);
3715
+ std::unique_ptr<Expr> expr = parser->parse_expr ();
3724
3716
// stream_pos++;
3725
3717
/* shouldn't be required anymore due to parsing literal actually
3726
3718
* skipping the token */
3727
- return std::unique_ptr<MetaItemPathLit > (
3728
- new MetaItemPathLit (std::move (path), std::move (expr)));
3719
+ return std::unique_ptr<MetaItemPathExpr > (
3720
+ new MetaItemPathExpr (std::move (path), std::move (expr)));
3729
3721
}
3730
3722
case COMMA:
3731
3723
// just simple path
@@ -4144,10 +4136,12 @@ MetaNameValueStr::check_cfg_predicate (const Session &session) const
4144
4136
}
4145
4137
4146
4138
bool
4147
- MetaItemPathLit ::check_cfg_predicate (const Session &session) const
4139
+ MetaItemPathExpr ::check_cfg_predicate (const Session &session) const
4148
4140
{
4141
+ // FIXME: Accept path expressions
4142
+ rust_assert (expr->is_literal ());
4149
4143
return session.options .target_data .has_key_value_pair (path.as_string (),
4150
- lit. as_string ());
4144
+ expr-> as_string ());
4151
4145
}
4152
4146
4153
4147
std::vector<std::unique_ptr<Token>>
@@ -4235,8 +4229,10 @@ MetaListNameValueStr::to_attribute () const
4235
4229
}
4236
4230
4237
4231
Attribute
4238
- MetaItemPathLit ::to_attribute () const
4232
+ MetaItemPathExpr ::to_attribute () const
4239
4233
{
4234
+ rust_assert (expr->is_literal ());
4235
+ auto &lit = static_cast <LiteralExpr &> (*expr);
4240
4236
return Attribute (path, std::unique_ptr<AttrInputLiteral> (
4241
4237
new AttrInputLiteral (lit)));
4242
4238
}
@@ -4406,7 +4402,7 @@ MetaItemLitExpr::accept_vis (ASTVisitor &vis)
4406
4402
}
4407
4403
4408
4404
void
4409
- MetaItemPathLit ::accept_vis (ASTVisitor &vis)
4405
+ MetaItemPathExpr ::accept_vis (ASTVisitor &vis)
4410
4406
{
4411
4407
vis.visit (*this );
4412
4408
}
0 commit comments