@@ -288,7 +288,7 @@ Attribute::get_traits_to_derive ()
288288 break ;
289289 case AST::MetaItem::ItemKind::ListPaths:
290290 case AST::MetaItem::ItemKind::NameValueStr:
291- case AST::MetaItem::ItemKind::PathLit :
291+ case AST::MetaItem::ItemKind::PathExpr :
292292 case AST::MetaItem::ItemKind::Seq:
293293 case AST::MetaItem::ItemKind::ListNameValueStr:
294294 default :
@@ -3712,20 +3712,12 @@ AttributeParser::parse_path_meta_item ()
37123712 {
37133713 skip_token ();
37143714
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 ();
37243716 // stream_pos++;
37253717 /* shouldn't be required anymore due to parsing literal actually
37263718 * 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)));
37293721 }
37303722 case COMMA:
37313723 // just simple path
@@ -4144,10 +4136,12 @@ MetaNameValueStr::check_cfg_predicate (const Session &session) const
41444136}
41454137
41464138bool
4147- MetaItemPathLit ::check_cfg_predicate (const Session &session) const
4139+ MetaItemPathExpr ::check_cfg_predicate (const Session &session) const
41484140{
4141+ // FIXME: Accept path expressions
4142+ rust_assert (expr->is_literal ());
41494143 return session.options .target_data .has_key_value_pair (path.as_string (),
4150- lit. as_string ());
4144+ expr-> as_string ());
41514145}
41524146
41534147std::vector<std::unique_ptr<Token>>
@@ -4235,8 +4229,10 @@ MetaListNameValueStr::to_attribute () const
42354229}
42364230
42374231Attribute
4238- MetaItemPathLit ::to_attribute () const
4232+ MetaItemPathExpr ::to_attribute () const
42394233{
4234+ rust_assert (expr->is_literal ());
4235+ auto &lit = static_cast <LiteralExpr &> (*expr);
42404236 return Attribute (path, std::unique_ptr<AttrInputLiteral> (
42414237 new AttrInputLiteral (lit)));
42424238}
@@ -4406,7 +4402,7 @@ MetaItemLitExpr::accept_vis (ASTVisitor &vis)
44064402}
44074403
44084404void
4409- MetaItemPathLit ::accept_vis (ASTVisitor &vis)
4405+ MetaItemPathExpr ::accept_vis (ASTVisitor &vis)
44104406{
44114407 vis.visit (*this );
44124408}
0 commit comments