@@ -322,7 +322,8 @@ Attribute::get_traits_to_derive ()
322
322
}
323
323
break ;
324
324
case AST::AttrInput::TOKEN_TREE:
325
- case AST::AttrInput::EXPR:
325
+ case AST::AttrInput::LITERAL:
326
+ case AST::AttrInput::MACRO:
326
327
rust_unreachable ();
327
328
break ;
328
329
}
@@ -3343,9 +3344,9 @@ AttrInputMetaItemContainer::as_string () const
3343
3344
}
3344
3345
3345
3346
std::string
3346
- AttrInputExpr ::as_string () const
3347
+ AttrInputMacro ::as_string () const
3347
3348
{
3348
- return " = " + expr ->as_string ();
3349
+ return " = " + macro ->as_string ();
3349
3350
}
3350
3351
3351
3352
/* Override that calls the function recursively on all items contained within
@@ -4055,14 +4056,14 @@ Token::to_token_stream () const
4055
4056
Attribute
4056
4057
MetaNameValueStr::to_attribute () const
4057
4058
{
4058
- auto lit_expr = std::make_unique<AST::LiteralExpr> (str, Literal::LitType::STRING,
4059
- PrimitiveCoreType::CORETYPE_UNKNOWN, std::vector<Attribute> () , str_locus);
4059
+ LiteralExpr lit_expr (str, Literal::LitType::STRING,
4060
+ PrimitiveCoreType::CORETYPE_UNKNOWN, {} , str_locus);
4060
4061
// FIXME: What location do we put here? Is the literal above supposed to have
4061
4062
// an empty location as well?
4062
4063
// Should MetaNameValueStr keep a location?
4063
4064
return Attribute (SimplePath::from_str (ident.as_string (), ident_locus),
4064
- std::unique_ptr<AttrInputExpr > (
4065
- new AttrInputExpr (std::move (lit_expr))));
4065
+ std::unique_ptr<AttrInputLiteral > (
4066
+ new AttrInputLiteral (std::move (lit_expr))));
4066
4067
}
4067
4068
4068
4069
Attribute
@@ -4128,9 +4129,10 @@ MetaListNameValueStr::to_attribute () const
4128
4129
Attribute
4129
4130
MetaItemPathExpr::to_attribute () const
4130
4131
{
4131
- // TODO: should we move instead of clone?
4132
- return Attribute (path, std::unique_ptr<AttrInputExpr> (
4133
- new AttrInputExpr (expr->clone_expr ())));
4132
+ rust_assert (expr->is_literal ());
4133
+ auto &lit = static_cast <LiteralExpr &> (*expr);
4134
+ return Attribute (path, std::unique_ptr<AttrInputLiteral> (
4135
+ new AttrInputLiteral (lit)));
4134
4136
}
4135
4137
4136
4138
std::vector<Attribute>
@@ -4234,6 +4236,19 @@ BlockExpr::normalize_tail_expr ()
4234
4236
}
4235
4237
}
4236
4238
4239
+ // needed here because "rust-expr.h" doesn't include "rust-macro.h"
4240
+ AttrInputMacro::AttrInputMacro (const AttrInputMacro &oth)
4241
+ : macro (oth.macro->clone_macro_invocation_impl ())
4242
+ {}
4243
+
4244
+ AttrInputMacro &
4245
+ AttrInputMacro::operator = (const AttrInputMacro &oth)
4246
+ {
4247
+ macro = std::unique_ptr<MacroInvocation> (
4248
+ oth.macro ->clone_macro_invocation_impl ());
4249
+ return *this ;
4250
+ }
4251
+
4237
4252
/* Visitor implementations - these are short but inlining can't happen anyway
4238
4253
* due to virtual functions and I didn't want to make the ast header includes
4239
4254
* any longer than they already are. */
@@ -4275,7 +4290,13 @@ LiteralExpr::accept_vis (ASTVisitor &vis)
4275
4290
}
4276
4291
4277
4292
void
4278
- AttrInputExpr::accept_vis (ASTVisitor &vis)
4293
+ AttrInputLiteral::accept_vis (ASTVisitor &vis)
4294
+ {
4295
+ vis.visit (*this );
4296
+ }
4297
+
4298
+ void
4299
+ AttrInputMacro::accept_vis (ASTVisitor &vis)
4279
4300
{
4280
4301
vis.visit (*this );
4281
4302
}
0 commit comments