aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-06-27 11:22:00 +0200
committerCohenArthur <arthur.cohen@embecosm.com>2023-06-29 09:26:34 +0000
commitd5723ccebbf62ed4546c5e2b2141b274585dd64c (patch)
tree1b925f691054a3881a0175426f502b5b0193c5b8 /gcc/rust/resolve
parent3d2a0c0445c2a1417dcc290b7a14e551c14fa421 (diff)
downloadgcc-d5723ccebbf62ed4546c5e2b2141b274585dd64c.zip
gcc-d5723ccebbf62ed4546c5e2b2141b274585dd64c.tar.gz
gcc-d5723ccebbf62ed4546c5e2b2141b274585dd64c.tar.bz2
ast: Change Identifier definition
Change Identifier type definition from a simple typedef to a whole class with it's own node id. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Change with call to getter. * ast/rust-ast.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (Method::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (MacroRulesDefinition::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (MacroMatchFragment::as_string): Likewise. (TypeParam::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalTypeItem::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitMethodDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. (MetaListPaths::as_string): Likewise. (MetaListNameValueStr::as_string): Likewise. (Module::process_file_path): Likewise. (MetaListNameValueStr::check_cfg_predicate): Likewise. (MetaListPaths::check_cfg_predicate): Likewise. (MetaWord::check_cfg_predicate): Likewise. (MetaNameValueStr::check_cfg_predicate): Likewise. (MetaNameValueStr::to_attribute): Likewise. (MetaWord::to_attribute): Likewise. (MetaListPaths::to_attribute): Likewise. (MetaListNameValueStr::to_attribute): Likewise. (operator<<): Change Identifier class << operator overload for standard output stream. * ast/rust-ast.h (class Identifier): Change typedef to proper class definition. (operator<<): Add prototype for operator overload. (class Token): Change getter identifier. (class MetaListNameValueStr): Likewise. (class PathExpr): Likewise. * ast/rust-expr.h: Likewise. * ast/rust-item.h: Likewise. * ast/rust-macro.h: Likewise. * ast/rust-path.cc (GenericArg::disambiguate_to_type): Likewise. (GenericArgsBinding::as_string): Likewise. (ConstGenericParam::as_string): Likewise. * ast/rust-path.h: Likewise. * ast/rust-pattern.cc (IdentifierPattern::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. * ast/rust-type.h: Likewise. * backend/rust-compile-base.cc: Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-extern.h: Likewise. * backend/rust-compile-fnparam.cc (CompileFnParam::visit): Likewise. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * backend/rust-compile-pattern.cc (CompilePatternBindings::visit): Likewise. * backend/rust-compile-struct-field-expr.cc (CompileStructExprField::visit): Likewise. * backend/rust-compile-var-decl.h: Likewise. * backend/rust-compile.cc: Likewise. * checks/errors/rust-unsafe-checker.cc (check_extern_call): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. * checks/lints/rust-lint-scan-deadcode.h: Likewise. * expand/rust-derive-clone.cc (DeriveClone::clone_fn): Likewise. (DeriveClone::visit_tuple): Likewise. (DeriveClone::visit_struct): Likewise. (DeriveClone::visit_union): Likewise. * expand/rust-derive-copy.cc (DeriveCopy::visit_struct): Likewise. (DeriveCopy::visit_tuple): Likewise. (DeriveCopy::visit_enum): Likewise. (DeriveCopy::visit_union): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_matcher): Likewise. (MacroExpander::match_n_matches): Likewise. (MacroExpander::match_repetition): Likewise. (MacroExpander::match_repetition_skipped_metavars): Likewise. * hir/rust-ast-lower-base.cc (struct_field_name_exists): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/tree/rust-hir-expr.h: Likewise. * hir/tree/rust-hir-item.h: Likewise. * hir/tree/rust-hir-path.h: Likewise. * hir/tree/rust-hir-type.h: Likewise. * hir/tree/rust-hir.cc (Module::as_string): Likewise. (StaticItem::as_string): Likewise. (TupleStruct::as_string): Likewise. (ConstantItem::as_string): Likewise. (StructStruct::as_string): Likewise. (UseTreeRebind::as_string): Likewise. (Enum::as_string): Likewise. (Trait::as_string): Likewise. (Union::as_string): Likewise. (Function::as_string): Likewise. (TypeAlias::as_string): Likewise. (FieldAccessExpr::as_string): Likewise. (TypeParam::as_string): Likewise. (GenericArgsBinding::as_string): Likewise. (StructPatternFieldIdent::as_string): Likewise. (StructPatternFieldIdentPat::as_string): Likewise. (IdentifierPattern::as_string): Likewise. (StructExprFieldIdentifierValue::as_string): Likewise. (EnumItem::as_string): Likewise. (StructField::as_string): Likewise. (ExternalStaticItem::as_string): Likewise. (ExternalFunctionItem::as_string): Likewise. (NamedFunctionParam::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitItemConst::as_string): Likewise. (TraitItemType::as_string): Likewise. (MaybeNamedParam::as_string): Likewise. * hir/tree/rust-hir.h: Likewise. * parse/rust-parse-impl.h (Parser::parse_macro_match_fragment): Likewise. (Parser::parse_module): Likewise. (Parser::parse_use_tree): Likewise. (Parser::parse_maybe_named_param): Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. (flatten_rebind): Likewise. (ResolveExternItem::visit): Likewise. (rust_flatten_rebind): Likewise. (rust_flatten_rebind_nested): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go): Likewise. (PatternDeclaration::visit): Likewise. (PatternDeclaration::add_new_binding): Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Likewise. * typecheck/rust-autoderef.cc: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::select): Likewise. * typecheck/rust-hir-path-probe.cc (PathProbeType::visit): Likewise. * typecheck/rust-hir-trait-reference.cc (TraitReference::get_name): Likewise. * typecheck/rust-hir-trait-resolve.cc (ResolveTraitItemToRef::visit): Likewise. (TraitResolver::resolve_trait): Likewise. (TraitItemReference::resolve_item): Likewise. (AssociatedImplTrait::setup_raw_associated_types): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::visit): Likewise. (TypeCheckImplItemWithTrait::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionRef::get_mappings_from_generic_args): Likewise. * util/rust-attributes.cc (check_doc_attribute): Likewise. * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-implitem.h34
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc84
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-pattern.cc16
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-stmt.h37
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-toplevel.h58
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.h5
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver.cc4
7 files changed, 133 insertions, 105 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h
index 9cad8aa..8731bcc 100644
--- a/gcc/rust/resolve/rust-ast-resolve-implitem.h
+++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h
@@ -51,8 +51,8 @@ public:
void visit (AST::TypeAlias &type) override
{
- auto decl
- = CanonicalPath::new_seg (type.get_node_id (), type.get_new_type_name ());
+ auto decl = CanonicalPath::new_seg (type.get_node_id (),
+ type.get_new_type_name ().as_string ());
auto path = prefix.append (decl);
resolver->get_type_scope ().insert (
@@ -82,8 +82,9 @@ public:
void visit (AST::Function &function) override
{
- auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_function_name ());
+ auto decl
+ = CanonicalPath::new_seg (function.get_node_id (),
+ function.get_function_name ().as_string ());
auto path = prefix.append (decl);
resolver->get_name_scope ().insert (
@@ -99,7 +100,7 @@ public:
void visit (AST::Method &method) override
{
auto decl = CanonicalPath::new_seg (method.get_node_id (),
- method.get_method_name ());
+ method.get_method_name ().as_string ());
auto path = prefix.append (decl);
resolver->get_name_scope ().insert (
@@ -138,7 +139,7 @@ public:
{
auto decl = CanonicalPath::new_seg (
function.get_node_id (),
- function.get_trait_function_decl ().get_identifier ());
+ function.get_trait_function_decl ().get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -157,7 +158,8 @@ public:
void visit (AST::TraitItemMethod &method) override
{
auto decl = CanonicalPath::new_seg (
- method.get_node_id (), method.get_trait_method_decl ().get_identifier ());
+ method.get_node_id (),
+ method.get_trait_method_decl ().get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -175,8 +177,9 @@ public:
void visit (AST::TraitItemConst &constant) override
{
- auto decl = CanonicalPath::new_seg (constant.get_node_id (),
- constant.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (constant.get_node_id (),
+ constant.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -194,8 +197,8 @@ public:
void visit (AST::TraitItemType &type) override
{
- auto decl
- = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ());
+ auto decl = CanonicalPath::new_seg (type.get_node_id (),
+ type.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -233,8 +236,9 @@ public:
void visit (AST::ExternalFunctionItem &function) override
{
- auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (function.get_node_id (),
+ function.get_identifier ().as_string ());
auto path = prefix.append (decl);
resolver->get_name_scope ().insert (
@@ -252,8 +256,8 @@ public:
void visit (AST::ExternalStaticItem &item) override
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
resolver->get_name_scope ().insert (
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index e70383e..99752bd 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -46,8 +46,8 @@ ResolveTraitItems::go (AST::TraitItem *item, const CanonicalPath &prefix,
void
ResolveTraitItems::visit (AST::TraitItemType &type)
{
- auto decl
- = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ());
+ auto decl = CanonicalPath::new_seg (type.get_node_id (),
+ type.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (type.get_node_id (), cpath);
@@ -60,7 +60,8 @@ void
ResolveTraitItems::visit (AST::TraitItemFunc &func)
{
auto decl = CanonicalPath::new_seg (
- func.get_node_id (), func.get_trait_function_decl ().get_identifier ());
+ func.get_node_id (),
+ func.get_trait_function_decl ().get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (func.get_node_id (), cpath);
@@ -108,9 +109,9 @@ ResolveTraitItems::visit (AST::TraitItemFunc &func)
void
ResolveTraitItems::visit (AST::TraitItemMethod &func)
{
- auto decl
- = CanonicalPath::new_seg (func.get_node_id (),
- func.get_trait_method_decl ().get_identifier ());
+ auto decl = CanonicalPath::new_seg (
+ func.get_node_id (),
+ func.get_trait_method_decl ().get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (func.get_node_id (), cpath);
@@ -133,7 +134,7 @@ ResolveTraitItems::visit (AST::TraitItemMethod &func)
// self turns into (self: Self) as a function param
AST::SelfParam &self_param = function.get_self_param ();
- AST::IdentifierPattern self_pattern (self_param.get_node_id (), "self",
+ AST::IdentifierPattern self_pattern (self_param.get_node_id (), {"self"},
self_param.get_locus (),
self_param.get_has_ref (),
self_param.get_is_mut (),
@@ -186,7 +187,7 @@ void
ResolveTraitItems::visit (AST::TraitItemConst &constant)
{
auto decl = CanonicalPath::new_seg (constant.get_node_id (),
- constant.get_identifier ());
+ constant.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (constant.get_node_id (), cpath);
@@ -214,7 +215,8 @@ void
ResolveItem::visit (AST::TypeAlias &alias)
{
auto talias
- = CanonicalPath::new_seg (alias.get_node_id (), alias.get_new_type_name ());
+ = CanonicalPath::new_seg (alias.get_node_id (),
+ alias.get_new_type_name ().as_string ());
auto path = prefix.append (talias);
auto cpath = canonical_prefix.append (talias);
mappings->insert_canonical_path (alias.get_node_id (), cpath);
@@ -237,7 +239,8 @@ ResolveItem::visit (AST::TypeAlias &alias)
void
ResolveItem::visit (AST::Module &module)
{
- auto mod = CanonicalPath::new_seg (module.get_node_id (), module.get_name ());
+ auto mod = CanonicalPath::new_seg (module.get_node_id (),
+ module.get_name ().as_string ());
auto path = prefix.append (mod);
auto cpath = canonical_prefix.append (mod);
mappings->insert_canonical_path (module.get_node_id (), cpath);
@@ -271,8 +274,9 @@ ResolveItem::visit (AST::Module &module)
void
ResolveItem::visit (AST::TupleStruct &struct_decl)
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
@@ -306,7 +310,7 @@ void
ResolveItem::visit (AST::Enum &enum_decl)
{
auto decl = CanonicalPath::new_seg (enum_decl.get_node_id (),
- enum_decl.get_identifier ());
+ enum_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
@@ -337,8 +341,8 @@ ResolveItem::visit (AST::EnumItem &item)
// Since at this point we cannot have visibilities on enum items anymore, we
// can skip handling them
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -347,8 +351,8 @@ ResolveItem::visit (AST::EnumItem &item)
void
ResolveItem::visit (AST::EnumItemTuple &item)
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -365,8 +369,8 @@ ResolveItem::visit (AST::EnumItemTuple &item)
void
ResolveItem::visit (AST::EnumItemStruct &item)
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -383,8 +387,8 @@ ResolveItem::visit (AST::EnumItemStruct &item)
void
ResolveItem::visit (AST::EnumItemDiscriminant &item)
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -394,8 +398,9 @@ ResolveItem::visit (AST::EnumItemDiscriminant &item)
void
ResolveItem::visit (AST::StructStruct &struct_decl)
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
@@ -428,8 +433,9 @@ ResolveItem::visit (AST::StructStruct &struct_decl)
void
ResolveItem::visit (AST::Union &union_decl)
{
- auto decl = CanonicalPath::new_seg (union_decl.get_node_id (),
- union_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (union_decl.get_node_id (),
+ union_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
@@ -460,8 +466,8 @@ ResolveItem::visit (AST::Union &union_decl)
void
ResolveItem::visit (AST::StaticItem &var)
{
- auto decl
- = CanonicalPath::new_seg (var.get_node_id (), var.get_identifier ());
+ auto decl = CanonicalPath::new_seg (var.get_node_id (),
+ var.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (var.get_node_id (), cpath);
@@ -488,8 +494,9 @@ ResolveItem::visit (AST::ConstantItem &constant)
void
ResolveItem::visit (AST::Function &function)
{
- auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_function_name ());
+ auto decl
+ = CanonicalPath::new_seg (function.get_node_id (),
+ function.get_function_name ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -611,8 +618,8 @@ ResolveItem::visit (AST::InherentImpl &impl_block)
void
ResolveItem::visit (AST::Method &method)
{
- auto decl
- = CanonicalPath::new_seg (method.get_node_id (), method.get_method_name ());
+ auto decl = CanonicalPath::new_seg (method.get_node_id (),
+ method.get_method_name ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (method.get_node_id (), cpath);
@@ -641,7 +648,7 @@ ResolveItem::visit (AST::Method &method)
// self turns into (self: Self) as a function param
AST::SelfParam &self_param = method.get_self_param ();
- AST::IdentifierPattern self_pattern (self_param.get_node_id (), "self",
+ AST::IdentifierPattern self_pattern (self_param.get_node_id (), {"self"},
self_param.get_locus (),
self_param.get_has_ref (),
self_param.get_is_mut (),
@@ -818,7 +825,7 @@ ResolveItem::visit (AST::Trait &trait)
// we need to inject an implicit self TypeParam here
AST::TypeParam *implicit_self
- = new AST::TypeParam ("Self", trait.get_locus ());
+ = new AST::TypeParam ({"Self"}, trait.get_locus ());
trait.insert_implict_self (
std::unique_ptr<AST::GenericParam> (implicit_self));
CanonicalPath Self = CanonicalPath::get_big_self (trait.get_node_id ());
@@ -946,7 +953,7 @@ flatten_rebind (const AST::UseTreeRebind &rebind,
// Add the identifier as a new path
rebind_path.get_segments ().back ()
- = AST::SimplePathSegment (new_seg, Location ());
+ = AST::SimplePathSegment (new_seg.as_string (), Location ());
paths.emplace_back (rebind_path);
}
@@ -1095,7 +1102,7 @@ ResolveExternItem::visit (AST::ExternalFunctionItem &function)
{
NodeId scope_node_id = function.get_node_id ();
auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_identifier ());
+ function.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -1208,7 +1215,7 @@ rust_flatten_rebind (void)
auto frob = Rust::AST::SimplePath::from_str ("frobulator", Location ());
auto rebind = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::IDENTIFIER,
- frob, Location (), "saindoux");
+ frob, Location (), {"saindoux"});
auto paths = std::vector<Rust::AST::SimplePath> ();
Rust::Resolver::flatten_rebind (rebind, paths);
@@ -1228,8 +1235,9 @@ rust_flatten_rebind_nested (void)
auto foo_bar_baz = Rust::AST::SimplePath ({foo, bar, baz});
- auto rebind = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::IDENTIFIER,
- foo_bar_baz, Location (), "saindoux");
+ auto rebind
+ = Rust::AST::UseTreeRebind (Rust::AST::UseTreeRebind::IDENTIFIER,
+ foo_bar_baz, Location (), {"saindoux"});
auto paths = std::vector<Rust::AST::SimplePath> ();
Rust::Resolver::flatten_rebind (rebind, paths);
diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.cc b/gcc/rust/resolve/rust-ast-resolve-pattern.cc
index cb3e69f..5bd65c4 100644
--- a/gcc/rust/resolve/rust-ast-resolve-pattern.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-pattern.cc
@@ -44,7 +44,7 @@ PatternDeclaration::go (AST::Pattern *pattern, Rib::ItemType type,
rust_error_at (info.get_locus (), ErrorCode ("E0408"),
"variable '%s' is not bound in all patterns",
- ident.c_str ());
+ ident.as_string ().c_str ());
}
for (auto &map_entry : resolver.inconsistent_bindings)
@@ -55,7 +55,7 @@ PatternDeclaration::go (AST::Pattern *pattern, Rib::ItemType type,
rust_error_at (
info.get_locus (), ErrorCode ("E0409"),
"variable '%s' is bound inconsistently across pattern alternatives",
- ident.c_str ());
+ ident.as_string ().c_str ());
}
}
@@ -244,7 +244,7 @@ PatternDeclaration::visit (AST::AltPattern &pattern)
auto idents = bindings_with_ctx.back ().idents;
bindings_with_ctx.pop_back ();
for (auto &ident : idents)
- bindings_with_ctx.back ().idents.insert (ident);
+ bindings_with_ctx.back ().idents.insert (ident.as_string ());
// ...we repopulate the binding_info_map correctly (the initial bindings
// stored in the tmp_binding_map + all the bindings from all the alts)
@@ -281,14 +281,14 @@ PatternDeclaration::add_new_binding (Identifier ident, NodeId node_id,
rust_error_at (info.get_locus (), ErrorCode ("E0415"),
"identifier '%s' is bound more than once in the "
"same parameter list",
- ident.c_str ());
+ ident.as_string ().c_str ());
}
else
{
rust_error_at (
info.get_locus (), ErrorCode ("E0416"),
"identifier '%s' is bound more than once in the same pattern",
- ident.c_str ());
+ ident.as_string ().c_str ());
}
return;
@@ -297,9 +297,9 @@ PatternDeclaration::add_new_binding (Identifier ident, NodeId node_id,
if (!identifier_or_bound)
{
bindings_with_ctx.back ().idents.insert (ident);
- resolver->get_name_scope ().insert (CanonicalPath::new_seg (node_id,
- ident),
- node_id, info.get_locus (), type);
+ resolver->get_name_scope ().insert (
+ CanonicalPath::new_seg (node_id, ident.as_string ()), node_id,
+ info.get_locus (), type);
}
binding_info_map.insert ({ident, info});
diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h
index 7511b22..9703387 100644
--- a/gcc/rust/resolve/rust-ast-resolve-stmt.h
+++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h
@@ -84,8 +84,9 @@ public:
void visit (AST::TupleStruct &struct_decl) override
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
@@ -116,8 +117,9 @@ public:
void visit (AST::Enum &enum_decl) override
{
- auto decl = CanonicalPath::new_seg (enum_decl.get_node_id (),
- enum_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (enum_decl.get_node_id (),
+ enum_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
@@ -149,7 +151,8 @@ public:
void visit (AST::EnumItem &item) override
{
auto decl = enum_prefix.append (
- CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ()));
+ CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -168,7 +171,8 @@ public:
void visit (AST::EnumItemTuple &item) override
{
auto decl = enum_prefix.append (
- CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ()));
+ CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -193,7 +197,8 @@ public:
void visit (AST::EnumItemStruct &item) override
{
auto decl = enum_prefix.append (
- CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ()));
+ CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -218,7 +223,8 @@ public:
void visit (AST::EnumItemDiscriminant &item) override
{
auto decl = enum_prefix.append (
- CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ()));
+ CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
@@ -236,8 +242,9 @@ public:
void visit (AST::StructStruct &struct_decl) override
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
@@ -273,8 +280,9 @@ public:
void visit (AST::Union &union_decl) override
{
- auto decl = CanonicalPath::new_seg (union_decl.get_node_id (),
- union_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (union_decl.get_node_id (),
+ union_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
@@ -308,8 +316,9 @@ public:
void visit (AST::Function &function) override
{
- auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_function_name ());
+ auto decl
+ = CanonicalPath::new_seg (function.get_node_id (),
+ function.get_function_name ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
index d784317..a55ce74 100644
--- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h
+++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
@@ -47,8 +47,8 @@ public:
void visit (AST::Module &module) override
{
- auto mod
- = CanonicalPath::new_seg (module.get_node_id (), module.get_name ());
+ auto mod = CanonicalPath::new_seg (module.get_node_id (),
+ module.get_name ().as_string ());
auto path = prefix.append (mod);
auto cpath = canonical_prefix.append (mod);
@@ -76,8 +76,9 @@ public:
void visit (AST::TypeAlias &alias) override
{
- auto talias = CanonicalPath::new_seg (alias.get_node_id (),
- alias.get_new_type_name ());
+ auto talias
+ = CanonicalPath::new_seg (alias.get_node_id (),
+ alias.get_new_type_name ().as_string ());
auto path = prefix.append (talias);
auto cpath = canonical_prefix.append (talias);
@@ -97,8 +98,9 @@ public:
void visit (AST::TupleStruct &struct_decl) override
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -118,8 +120,9 @@ public:
void visit (AST::Enum &enum_decl) override
{
- auto decl = CanonicalPath::new_seg (enum_decl.get_node_id (),
- enum_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (enum_decl.get_node_id (),
+ enum_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -145,8 +148,8 @@ public:
void visit (AST::EnumItem &item) override
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -167,8 +170,8 @@ public:
void visit (AST::EnumItemTuple &item) override
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -189,8 +192,8 @@ public:
void visit (AST::EnumItemStruct &item) override
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -211,8 +214,8 @@ public:
void visit (AST::EnumItemDiscriminant &item) override
{
- auto decl
- = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto decl = CanonicalPath::new_seg (item.get_node_id (),
+ item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -233,8 +236,9 @@ public:
void visit (AST::StructStruct &struct_decl) override
{
- auto decl = CanonicalPath::new_seg (struct_decl.get_node_id (),
- struct_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (struct_decl.get_node_id (),
+ struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -254,8 +258,9 @@ public:
void visit (AST::Union &union_decl) override
{
- auto decl = CanonicalPath::new_seg (union_decl.get_node_id (),
- union_decl.get_identifier ());
+ auto decl
+ = CanonicalPath::new_seg (union_decl.get_node_id (),
+ union_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -275,8 +280,8 @@ public:
void visit (AST::StaticItem &var) override
{
- auto decl
- = CanonicalPath::new_seg (var.get_node_id (), var.get_identifier ());
+ auto decl = CanonicalPath::new_seg (var.get_node_id (),
+ var.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -316,8 +321,9 @@ public:
void visit (AST::Function &function) override
{
- auto decl = CanonicalPath::new_seg (function.get_node_id (),
- function.get_function_name ());
+ auto decl
+ = CanonicalPath::new_seg (function.get_node_id (),
+ function.get_function_name ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
@@ -380,8 +386,8 @@ public:
void visit (AST::Trait &trait) override
{
- auto decl
- = CanonicalPath::new_seg (trait.get_node_id (), trait.get_identifier ());
+ auto decl = CanonicalPath::new_seg (trait.get_node_id (),
+ trait.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index f98ed8f..ef1ccec 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -173,8 +173,9 @@ public:
}
}
- auto seg = CanonicalPath::new_seg (param.get_node_id (),
- param.get_type_representation ());
+ auto seg
+ = CanonicalPath::new_seg (param.get_node_id (),
+ param.get_type_representation ().as_string ());
resolver->get_type_scope ().insert (
seg, param.get_node_id (), param.get_locus (), false, Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index 3a2d6a5..e460e6e 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -901,7 +901,7 @@ void
EarlyNameResolver::visit (AST::MacroRulesDefinition &rules_def)
{
auto path = CanonicalPath::new_seg (rules_def.get_node_id (),
- rules_def.get_rule_name ());
+ rules_def.get_rule_name ().as_string ());
resolver.get_macro_scope ().insert (path, rules_def.get_node_id (),
rules_def.get_locus ());
@@ -979,7 +979,7 @@ EarlyNameResolver::visit (AST::MacroInvocation &invoc)
if (is_builtin)
{
auto builtin_kind
- = builtin_macro_from_string (rules_def->get_rule_name ());
+ = builtin_macro_from_string (rules_def->get_rule_name ().as_string ());
invoc.map_to_builtin (builtin_kind);
}