We wish to remove node ids from identifiers, because they do not make
that much sense and are only used for procedural macros anyway. This
means we either have to wrap those into a structure or converting them
to an existing structure that already have a node id. This commit
convert those meta word identifiers to a meta path SimplePath.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add new constructor for SimplePath from an
identifier.
* expand/rust-expand-visitor.cc (get_traits_to_derive): Add
conversion.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
node_id (Analysis::Mappings::get ()->get_next_node_id ())
{}
+ SimplePath (Identifier ident)
+ : opening_scope_resolution (false),
+ segments ({SimplePathSegment (ident.as_string (), ident.get_locus ())}),
+ locus (ident.get_locus ()),
+ node_id (Analysis::Mappings::get ()->get_next_node_id ())
+ {}
+
// Creates an empty SimplePath.
static SimplePath create_empty ()
{
break;
case AST::MetaItem::ItemKind::Word: {
auto word = static_cast<AST::MetaWord *> (meta_item);
+ // Convert current word to path
+ current
+ = make_unique<AST::MetaItemPath> (AST::MetaItemPath (
+ AST::SimplePath (word->get_ident ())));
+ auto path
+ = static_cast<AST::MetaItemPath *> (current.get ());
+
result.push_back (
- Rust::make_unique<Identifier> (word->get_ident ()));
+ make_unique<AST::SimplePath> (path->get_path ()));
}
break;
case AST::MetaItem::ItemKind::ListPaths: