aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-base.h2
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-implitem.h12
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc36
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-path.cc14
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-stmt.h20
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-toplevel.h78
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.cc12
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.h2
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc6
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.h2
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver-2.0.cc22
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver.cc2
-rw-r--r--gcc/rust/resolve/rust-late-name-resolver-2.0.cc4
-rw-r--r--gcc/rust/resolve/rust-name-resolution-context.cc2
-rw-r--r--gcc/rust/resolve/rust-name-resolver.cc50
-rw-r--r--gcc/rust/resolve/rust-name-resolver.h2
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc30
17 files changed, 147 insertions, 149 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.h b/gcc/rust/resolve/rust-ast-resolve-base.h
index 648243b6fb6..e61ccabb99e 100644
--- a/gcc/rust/resolve/rust-ast-resolve-base.h
+++ b/gcc/rust/resolve/rust-ast-resolve-base.h
@@ -212,7 +212,7 @@ protected:
bool resolve_visibility (const AST::Visibility &vis);
Resolver *resolver;
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
NodeId resolved_node;
};
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h
index 641a6cfa754..c2396454f34 100644
--- a/gcc/rust/resolve/rust-ast-resolve-implitem.h
+++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h
@@ -127,7 +127,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (function.get_node_id (), cpath);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
}
void visit (AST::TraitItemConst &constant) override
@@ -147,7 +147,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (constant.get_node_id (), cpath);
+ mappings.insert_canonical_path (constant.get_node_id (), cpath);
}
void visit (AST::TraitItemType &type) override
@@ -165,7 +165,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (type.get_node_id (), cpath);
+ mappings.insert_canonical_path (type.get_node_id (), cpath);
}
private:
@@ -206,7 +206,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
+ mappings.insert_module_child_item (current_module, decl);
}
void visit (AST::ExternalStaticItem &item) override
@@ -225,7 +225,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
+ mappings.insert_module_child_item (current_module, decl);
}
void visit (AST::ExternalTypeItem &type) override
@@ -244,7 +244,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
+ mappings.insert_module_child_item (current_module, decl);
}
private:
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index d11a78859ef..bf47c73495c 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -53,7 +53,7 @@ ResolveTraitItems::visit (AST::Function &function)
function.get_function_name ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (function.get_node_id (), cpath);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
NodeId scope_node_id = function.get_node_id ();
resolver->get_name_scope ().push (scope_node_id);
@@ -140,7 +140,7 @@ ResolveTraitItems::visit (AST::TraitItemType &type)
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);
+ mappings.insert_canonical_path (type.get_node_id (), cpath);
for (auto &bound : type.get_type_param_bounds ())
ResolveTypeBound::go (*bound);
@@ -153,7 +153,7 @@ ResolveTraitItems::visit (AST::TraitItemConst &constant)
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);
+ mappings.insert_canonical_path (constant.get_node_id (), cpath);
ResolveType::go (constant.get_type ());
@@ -182,7 +182,7 @@ ResolveItem::visit (AST::TypeAlias &alias)
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);
+ mappings.insert_canonical_path (alias.get_node_id (), cpath);
NodeId scope_node_id = alias.get_node_id ();
resolver->get_type_scope ().push (scope_node_id);
@@ -206,7 +206,7 @@ ResolveItem::visit (AST::Module &module)
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);
+ mappings.insert_canonical_path (module.get_node_id (), cpath);
resolve_visibility (module.get_visibility ());
@@ -242,7 +242,7 @@ ResolveItem::visit (AST::TupleStruct &struct_decl)
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);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolve_visibility (struct_decl.get_visibility ());
@@ -276,7 +276,7 @@ ResolveItem::visit (AST::Enum &enum_decl)
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);
+ mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
resolve_visibility (enum_decl.get_visibility ());
@@ -308,7 +308,7 @@ ResolveItem::visit (AST::EnumItem &item)
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
}
void
@@ -318,7 +318,7 @@ ResolveItem::visit (AST::EnumItemTuple &item)
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
for (auto &field : item.get_tuple_fields ())
{
@@ -336,7 +336,7 @@ ResolveItem::visit (AST::EnumItemStruct &item)
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
for (auto &field : item.get_struct_fields ())
{
@@ -355,7 +355,7 @@ ResolveItem::visit (AST::EnumItemDiscriminant &item)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (item.get_node_id (), cpath);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
}
void
@@ -366,7 +366,7 @@ ResolveItem::visit (AST::StructStruct &struct_decl)
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);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolve_visibility (struct_decl.get_visibility ());
@@ -401,7 +401,7 @@ ResolveItem::visit (AST::Union &union_decl)
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);
+ mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
resolve_visibility (union_decl.get_visibility ());
@@ -433,7 +433,7 @@ ResolveItem::visit (AST::StaticItem &var)
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);
+ mappings.insert_canonical_path (var.get_node_id (), cpath);
ResolveType::go (var.get_type ());
ResolveExpr::go (var.get_expr (), path, cpath);
@@ -446,7 +446,7 @@ ResolveItem::visit (AST::ConstantItem &constant)
constant.get_identifier ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (constant.get_node_id (), cpath);
+ mappings.insert_canonical_path (constant.get_node_id (), cpath);
resolve_visibility (constant.get_visibility ());
@@ -463,7 +463,7 @@ ResolveItem::visit (AST::Function &function)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (function.get_node_id (), cpath);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
resolve_visibility (function.get_visibility ());
@@ -961,7 +961,7 @@ ResolveItem::visit (AST::UseDeclaration &use_item)
continue;
auto decl = CanonicalPath::new_seg (resolved_node_id, import.get_name ());
- mappings->insert_module_child_item (current_module, decl);
+ mappings.insert_module_child_item (current_module, decl);
resolver->get_type_scope ().insert (decl, resolved_node_id,
path.get_locus (),
@@ -1016,7 +1016,7 @@ ResolveExternItem::visit (AST::Function &function)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (function.get_node_id (), cpath);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
resolve_visibility (function.get_visibility ());
diff --git a/gcc/rust/resolve/rust-ast-resolve-path.cc b/gcc/rust/resolve/rust-ast-resolve-path.cc
index ec590302367..b50f94f6c28 100644
--- a/gcc/rust/resolve/rust-ast-resolve-path.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-path.cc
@@ -165,8 +165,8 @@ ResolvePath::resolve_path (AST::PathInExpression &expr)
&& previous_resolved_node_id == module_scope_id)
{
tl::optional<CanonicalPath &> resolved_child
- = mappings->lookup_module_child (module_scope_id,
- ident_seg.as_string ());
+ = mappings.lookup_module_child (module_scope_id,
+ ident_seg.as_string ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@@ -197,8 +197,8 @@ ResolvePath::resolve_path (AST::PathInExpression &expr)
bool did_resolve_segment = resolved_node_id != UNKNOWN_NODEID;
if (did_resolve_segment)
{
- if (mappings->node_is_module (resolved_node_id)
- || mappings->node_is_crate (resolved_node_id))
+ if (mappings.node_is_module (resolved_node_id)
+ || mappings.node_is_crate (resolved_node_id))
{
module_scope_id = resolved_node_id;
}
@@ -304,8 +304,8 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
}
tl::optional<CanonicalPath &> resolved_child
- = mappings->lookup_module_child (module_scope_id,
- segment.get_segment_name ());
+ = mappings.lookup_module_child (module_scope_id,
+ segment.get_segment_name ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@@ -379,7 +379,7 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
return UNKNOWN_NODEID;
}
- if (mappings->node_is_module (resolved_node_id))
+ if (mappings.node_is_module (resolved_node_id))
{
module_scope_id = resolved_node_id;
}
diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h
index d699bdec557..7118b70d705 100644
--- a/gcc/rust/resolve/rust-ast-resolve-stmt.h
+++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h
@@ -55,7 +55,7 @@ public:
constant.get_identifier ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (constant.get_node_id (), cpath);
+ mappings.insert_canonical_path (constant.get_node_id (), cpath);
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
@@ -89,7 +89,7 @@ public:
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);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
@@ -122,7 +122,7 @@ public:
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);
+ mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, enum_decl.get_node_id (), enum_decl.get_locus (), false,
@@ -155,7 +155,7 @@ public:
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@@ -175,7 +175,7 @@ public:
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@@ -201,7 +201,7 @@ public:
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@@ -227,7 +227,7 @@ public:
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);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@@ -247,7 +247,7 @@ public:
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);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
@@ -285,7 +285,7 @@ public:
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);
+ mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, union_decl.get_node_id (), union_decl.get_locus (), false,
@@ -321,7 +321,7 @@ public:
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);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
index 75769281ca9..88d6dbb3cca 100644
--- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h
+++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
@@ -41,7 +41,7 @@ public:
item.accept_vis (resolver);
NodeId current_module = resolver.resolver->peek_current_module_scope ();
- resolver.mappings->insert_child_item_to_parent_module_mapping (
+ resolver.mappings.insert_child_item_to_parent_module_mapping (
item.get_node_id (), current_module);
}
@@ -62,8 +62,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, mod);
- mappings->insert_module_child (current_module, module.get_node_id ());
+ mappings.insert_module_child_item (current_module, mod);
+ mappings.insert_module_child (current_module, module.get_node_id ());
resolver->push_new_module_scope (module.get_node_id ());
for (auto &item : module.get_items ())
@@ -71,7 +71,7 @@ public:
resolver->pop_module_scope ();
- mappings->insert_canonical_path (module.get_node_id (), cpath);
+ mappings.insert_canonical_path (module.get_node_id (), cpath);
}
void visit (AST::TypeAlias &alias) override
@@ -92,8 +92,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, talias);
- mappings->insert_canonical_path (alias.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, talias);
+ mappings.insert_canonical_path (alias.get_node_id (), cpath);
}
void visit (AST::TupleStruct &struct_decl) override
@@ -114,8 +114,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
}
void visit (AST::Enum &enum_decl) override
@@ -142,8 +142,8 @@ public:
resolver->pop_module_scope ();
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
}
void visit (AST::EnumItem &item) override
@@ -161,11 +161,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (item.get_node_id (), cpath);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_module_child (current_module, item.get_node_id ());
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemTuple &item) override
@@ -183,11 +183,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (item.get_node_id (), cpath);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_module_child (current_module, item.get_node_id ());
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemStruct &item) override
@@ -205,11 +205,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (item.get_node_id (), cpath);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_module_child (current_module, item.get_node_id ());
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemDiscriminant &item) override
@@ -227,11 +227,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
- mappings->insert_canonical_path (item.get_node_id (), cpath);
+ mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_module_child (current_module, item.get_node_id ());
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::StructStruct &struct_decl) override
@@ -252,8 +252,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
}
void visit (AST::Union &union_decl) override
@@ -274,8 +274,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
}
void visit (AST::StaticItem &var) override
@@ -294,8 +294,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (var.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (var.get_node_id (), cpath);
}
void visit (AST::ConstantItem &constant) override
@@ -315,8 +315,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (constant.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (constant.get_node_id (), cpath);
}
void visit (AST::Function &function) override
@@ -337,8 +337,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (function.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (function.get_node_id (), cpath);
}
void visit (AST::InherentImpl &impl_block) override
@@ -408,8 +408,8 @@ public:
ResolveTopLevelTraitItems::go (item.get (), path, cpath);
NodeId current_module = resolver->peek_current_module_scope ();
- mappings->insert_module_child_item (current_module, decl);
- mappings->insert_canonical_path (trait.get_node_id (), cpath);
+ mappings.insert_module_child_item (current_module, decl);
+ mappings.insert_canonical_path (trait.get_node_id (), cpath);
}
void visit (AST::ExternBlock &extern_block) override
@@ -428,16 +428,16 @@ public:
NodeId resolved_crate = UNKNOWN_NODEID;
if (extern_crate.references_self ())
{
- CrateNum crate_num = mappings->get_current_crate ();
- bool ok = mappings->crate_num_to_nodeid (crate_num, resolved_crate);
+ CrateNum crate_num = mappings.get_current_crate ();
+ bool ok = mappings.crate_num_to_nodeid (crate_num, resolved_crate);
rust_assert (ok);
}
else
{
CrateNum found_crate_num = UNKNOWN_CRATENUM;
bool found
- = mappings->lookup_crate_name (extern_crate.get_referenced_crate (),
- found_crate_num);
+ = mappings.lookup_crate_name (extern_crate.get_referenced_crate (),
+ found_crate_num);
if (!found)
{
rust_error_at (extern_crate.get_locus (), "unknown crate %<%s%>",
@@ -446,7 +446,7 @@ public:
}
bool ok
- = mappings->crate_num_to_nodeid (found_crate_num, resolved_crate);
+ = mappings.crate_num_to_nodeid (found_crate_num, resolved_crate);
if (!ok)
{
rust_internal_error_at (extern_crate.get_locus (),
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc
index df1e7ee1a45..c0e67529dfc 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-type.cc
@@ -84,7 +84,7 @@ bool
ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
{
auto resolver = Resolver::get ();
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
NodeId module_scope_id = resolver->peek_current_module_scope ();
NodeId previous_resolved_node_id = module_scope_id;
@@ -199,8 +199,8 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
&& previous_resolved_node_id == module_scope_id)
{
tl::optional<CanonicalPath &> resolved_child
- = mappings->lookup_module_child (module_scope_id,
- ident_seg.as_string ());
+ = mappings.lookup_module_child (module_scope_id,
+ ident_seg.as_string ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@@ -231,8 +231,8 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
bool did_resolve_segment = resolved_node_id != UNKNOWN_NODEID;
if (did_resolve_segment)
{
- if (mappings->node_is_module (resolved_node_id)
- || mappings->node_is_crate (resolved_node_id))
+ if (mappings.node_is_module (resolved_node_id)
+ || mappings.node_is_crate (resolved_node_id))
{
module_scope_id = resolved_node_id;
}
@@ -377,7 +377,7 @@ ResolveTypeToCanonicalPath::visit (AST::TypePath &path)
return;
const CanonicalPath *type_path = nullptr;
- if (mappings->lookup_canonical_path (resolved_node, &type_path))
+ if (mappings.lookup_canonical_path (resolved_node, &type_path))
{
auto &final_seg = path.get_segments ().back ();
switch (final_seg->get_type ())
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index f1031e9b1ed..00695ffc2c0 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -184,7 +184,7 @@ public:
rust_error_at (locus, "was defined here");
});
- mappings->insert_canonical_path (param.get_node_id (), seg);
+ mappings.insert_canonical_path (param.get_node_id (), seg);
}
private:
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 4273ae34055..65472f4e59f 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -46,7 +46,7 @@ NameResolution::NameResolution ()
: resolver (Resolver::get ()), mappings (Analysis::Mappings::get ())
{
// these are global
- resolver->get_type_scope ().push (mappings->get_next_node_id ());
+ resolver->get_type_scope ().push (mappings.get_next_node_id ());
resolver->insert_builtin_types (resolver->get_type_scope ().peek ());
resolver->push_new_type_rib (resolver->get_type_scope ().peek ());
}
@@ -62,9 +62,9 @@ void
NameResolution::go (AST::Crate &crate)
{
// lookup current crate name
- CrateNum cnum = mappings->get_current_crate ();
+ CrateNum cnum = mappings.get_current_crate ();
std::string crate_name;
- bool ok = mappings->get_crate_name (cnum, crate_name);
+ bool ok = mappings.get_crate_name (cnum, crate_name);
rust_assert (ok);
// setup the ribs
diff --git a/gcc/rust/resolve/rust-ast-resolve.h b/gcc/rust/resolve/rust-ast-resolve.h
index b2dbcba2ade..9b2bc921aa3 100644
--- a/gcc/rust/resolve/rust-ast-resolve.h
+++ b/gcc/rust/resolve/rust-ast-resolve.h
@@ -40,7 +40,7 @@ private:
NameResolution ();
Resolver *resolver;
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
};
} // namespace Resolver
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index af148b0c1c0..8af4b024679 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -175,25 +175,25 @@ Early::visit (AST::MacroInvocation &invoc)
// now do we need to keep mappings or something? or insert "uses" into our
// ForeverStack? can we do that? are mappings simpler?
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
AST::MacroRulesDefinition *rules_def = nullptr;
- if (!mappings->lookup_macro_def (definition->get_node_id (), &rules_def))
+ if (!mappings.lookup_macro_def (definition->get_node_id (), &rules_def))
{
// Macro definition not found, maybe it is not expanded yet.
return;
}
AST::MacroRulesDefinition *tmp_def = nullptr;
- if (mappings->lookup_macro_invocation (invoc, &tmp_def))
+ if (mappings.lookup_macro_invocation (invoc, &tmp_def))
return;
- mappings->insert_macro_invocation (invoc, rules_def);
+ mappings.insert_macro_invocation (invoc, rules_def);
}
void
Early::visit_attributes (std::vector<AST::Attribute> &attrs)
{
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
for (auto &attr : attrs)
{
@@ -214,13 +214,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
continue;
}
- auto pm_def = mappings->lookup_derive_proc_macro_def (
+ auto pm_def = mappings.lookup_derive_proc_macro_def (
definition->get_node_id ());
rust_assert (pm_def.has_value ());
- mappings->insert_derive_proc_macro_invocation (trait,
- pm_def.value ());
+ mappings.insert_derive_proc_macro_invocation (trait,
+ pm_def.value ());
}
}
else if (Analysis::BuiltinAttributeMappings::get ()
@@ -236,13 +236,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
"could not resolve attribute macro invocation");
return;
}
- auto pm_def = mappings->lookup_attribute_proc_macro_def (
+ auto pm_def = mappings.lookup_attribute_proc_macro_def (
definition->get_node_id ());
rust_assert (pm_def.has_value ());
- mappings->insert_attribute_proc_macro_invocation (attr.get_path (),
- pm_def.value ());
+ mappings.insert_attribute_proc_macro_invocation (attr.get_path (),
+ pm_def.value ());
}
}
}
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index af44439cdab..83b6576fe69 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -74,7 +74,7 @@ EarlyNameResolver::accumulate_escaped_macros (AST::Module &module)
EarlyNameResolver::EarlyNameResolver ()
: current_scope (UNKNOWN_NODEID), resolver (*Resolver::get ()),
- mappings (*Analysis::Mappings::get ())
+ mappings (Analysis::Mappings::get ())
{}
void
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index f580c23377b..995c022fbed 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -34,13 +34,13 @@ Late::Late (NameResolutionContext &ctx) : DefaultResolver (ctx) {}
static NodeId
next_node_id ()
{
- return Analysis::Mappings::get ()->get_next_node_id ();
+ return Analysis::Mappings::get ().get_next_node_id ();
};
static HirId
next_hir_id ()
{
- return Analysis::Mappings::get ()->get_next_hir_id ();
+ return Analysis::Mappings::get ().get_next_hir_id ();
};
void
diff --git a/gcc/rust/resolve/rust-name-resolution-context.cc b/gcc/rust/resolve/rust-name-resolution-context.cc
index e8529b70bcb..1bf7ee2f29e 100644
--- a/gcc/rust/resolve/rust-name-resolution-context.cc
+++ b/gcc/rust/resolve/rust-name-resolution-context.cc
@@ -24,7 +24,7 @@ namespace Rust {
namespace Resolver2_0 {
NameResolutionContext::NameResolutionContext ()
- : mappings (*Analysis::Mappings::get ())
+ : mappings (Analysis::Mappings::get ())
{}
tl::expected<NodeId, DuplicateNameError>
diff --git a/gcc/rust/resolve/rust-name-resolver.cc b/gcc/rust/resolve/rust-name-resolver.cc
index e87ac49be1a..333e7ba70e6 100644
--- a/gcc/rust/resolve/rust-name-resolver.cc
+++ b/gcc/rust/resolve/rust-name-resolver.cc
@@ -274,10 +274,10 @@ Scope::decl_was_declared_here (NodeId def) const
Resolver::Resolver ()
: mappings (Analysis::Mappings::get ()), tyctx (TypeCheckContext::get ()),
- name_scope (Scope (mappings->get_current_crate ())),
- type_scope (Scope (mappings->get_current_crate ())),
- label_scope (Scope (mappings->get_current_crate ())),
- macro_scope (Scope (mappings->get_current_crate ())),
+ name_scope (Scope (mappings.get_current_crate ())),
+ type_scope (Scope (mappings.get_current_crate ())),
+ label_scope (Scope (mappings.get_current_crate ())),
+ macro_scope (Scope (mappings.get_current_crate ())),
global_type_node_id (UNKNOWN_NODEID), unit_ty_node_id (UNKNOWN_NODEID)
{
generate_builtins ();
@@ -383,34 +383,34 @@ void
Resolver::generate_builtins ()
{
auto u8
- = new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U8);
+ = new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U8);
auto u16
- = new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U16);
+ = new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U16);
auto u32
- = new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U32);
+ = new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U32);
auto u64
- = new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U64);
+ = new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U64);
auto u128
- = new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U128);
- auto i8 = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I8);
+ = new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U128);
+ auto i8 = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I8);
auto i16
- = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I16);
+ = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I16);
auto i32
- = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I32);
+ = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I32);
auto i64
- = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I64);
+ = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I64);
auto i128
- = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I128);
- auto rbool = new TyTy::BoolType (mappings->get_next_hir_id ());
+ = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I128);
+ auto rbool = new TyTy::BoolType (mappings.get_next_hir_id ());
auto f32
- = new TyTy::FloatType (mappings->get_next_hir_id (), TyTy::FloatType::F32);
+ = new TyTy::FloatType (mappings.get_next_hir_id (), TyTy::FloatType::F32);
auto f64
- = new TyTy::FloatType (mappings->get_next_hir_id (), TyTy::FloatType::F64);
- auto usize = new TyTy::USizeType (mappings->get_next_hir_id ());
- auto isize = new TyTy::ISizeType (mappings->get_next_hir_id ());
- auto char_tyty = new TyTy::CharType (mappings->get_next_hir_id ());
- auto str = new TyTy::StrType (mappings->get_next_hir_id ());
- auto never = new TyTy::NeverType (mappings->get_next_hir_id ());
+ = new TyTy::FloatType (mappings.get_next_hir_id (), TyTy::FloatType::F64);
+ auto usize = new TyTy::USizeType (mappings.get_next_hir_id ());
+ auto isize = new TyTy::ISizeType (mappings.get_next_hir_id ());
+ auto char_tyty = new TyTy::CharType (mappings.get_next_hir_id ());
+ auto str = new TyTy::StrType (mappings.get_next_hir_id ());
+ auto never = new TyTy::NeverType (mappings.get_next_hir_id ());
setup_builtin ("u8", u8);
setup_builtin ("u16", u16);
@@ -433,7 +433,7 @@ Resolver::generate_builtins ()
// unit type ()
TyTy::TupleType *unit_tyty
- = TyTy::TupleType::get_unit_type (mappings->get_next_hir_id ());
+ = TyTy::TupleType::get_unit_type (mappings.get_next_hir_id ());
std::vector<std::unique_ptr<AST::Type> > elems;
AST::TupleType *unit_type
= new AST::TupleType (std::move (elems), BUILTINS_LOCATION);
@@ -455,8 +455,8 @@ Resolver::setup_builtin (const std::string &name, TyTy::BaseType *tyty)
= new AST::TypePath (::std::move (segs), BUILTINS_LOCATION, false);
builtins.push_back (builtin_type);
tyctx->insert_builtin (tyty->get_ref (), builtin_type->get_node_id (), tyty);
- mappings->insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
- mappings->insert_canonical_path (
+ mappings.insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
+ mappings.insert_canonical_path (
builtin_type->get_node_id (),
CanonicalPath::new_seg (builtin_type->get_node_id (), name));
}
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h
index 23d3c1c26c0..8da1a2a0c5a 100644
--- a/gcc/rust/resolve/rust-name-resolver.h
+++ b/gcc/rust/resolve/rust-name-resolver.h
@@ -210,7 +210,7 @@ private:
void generate_builtins ();
void setup_builtin (const std::string &name, TyTy::BaseType *tyty);
- Analysis::Mappings *mappings;
+ Analysis::Mappings &mappings;
TypeCheckContext *tyctx;
std::vector<AST::Type *> builtins;
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 4593c67c5d3..e25714c6509 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -182,9 +182,9 @@ TopLevel::visit (AST::Module &module)
ctx.scoped (Rib::Kind::Module, module.get_node_id (), sub_visitor,
module.get_name ());
- if (Analysis::Mappings::get ()->lookup_ast_module (module.get_node_id ())
+ if (Analysis::Mappings::get ().lookup_ast_module (module.get_node_id ())
== tl::nullopt)
- Analysis::Mappings::get ()->insert_ast_module (&module);
+ Analysis::Mappings::get ().insert_ast_module (&module);
}
void
@@ -230,17 +230,15 @@ insert_macros (std::vector<PROC_MACRO> &macros, NameResolutionContext &ctx)
void
TopLevel::visit (AST::ExternCrate &crate)
{
+ auto &mappings = Analysis::Mappings::get ();
CrateNum num;
- rust_assert (Analysis::Mappings::get ()->lookup_crate_name (
- crate.get_referenced_crate (), num));
+ rust_assert (mappings.lookup_crate_name (crate.get_referenced_crate (), num));
- auto attribute_macros
- = Analysis::Mappings::get ()->lookup_attribute_proc_macros (num);
+ auto attribute_macros = mappings.lookup_attribute_proc_macros (num);
- auto bang_macros = Analysis::Mappings::get ()->lookup_bang_proc_macros (num);
+ auto bang_macros = mappings.lookup_bang_proc_macros (num);
- auto derive_macros
- = Analysis::Mappings::get ()->lookup_derive_proc_macros (num);
+ auto derive_macros = mappings.lookup_derive_proc_macros (num);
auto sub_visitor = [&] () {
// TODO: Find a way to keep this part clean without the double dispatch.
@@ -248,19 +246,19 @@ TopLevel::visit (AST::ExternCrate &crate)
{
insert_macros (derive_macros.value (), ctx);
for (auto &macro : derive_macros.value ())
- Analysis::Mappings::get ()->insert_derive_proc_macro_def (macro);
+ mappings.insert_derive_proc_macro_def (macro);
}
if (attribute_macros.has_value ())
{
insert_macros (attribute_macros.value (), ctx);
for (auto &macro : attribute_macros.value ())
- Analysis::Mappings::get ()->insert_attribute_proc_macro_def (macro);
+ mappings.insert_attribute_proc_macro_def (macro);
}
if (bang_macros.has_value ())
{
insert_macros (bang_macros.value (), ctx);
for (auto &macro : bang_macros.value ())
- Analysis::Mappings::get ()->insert_bang_proc_macro_def (macro);
+ mappings.insert_bang_proc_macro_def (macro);
}
};
@@ -309,12 +307,12 @@ TopLevel::visit (AST::MacroRulesDefinition &macro)
if (macro.get_kind () == AST::MacroRulesDefinition::MacroKind::DeclMacro)
insert_or_error_out (macro.get_rule_name (), macro, Namespace::Macros);
- auto mappings = Analysis::Mappings::get ();
+ auto &mappings = Analysis::Mappings::get ();
AST::MacroRulesDefinition *tmp = nullptr;
- if (mappings->lookup_macro_def (macro.get_node_id (), &tmp))
+ if (mappings.lookup_macro_def (macro.get_node_id (), &tmp))
return;
- mappings->insert_macro_def (&macro);
+ mappings.insert_macro_def (&macro);
}
void
@@ -442,7 +440,7 @@ TopLevel::handle_use_glob (AST::SimplePath &glob)
return false;
auto result
- = Analysis::Mappings::get ()->lookup_ast_module (resolved->get_node_id ());
+ = Analysis::Mappings::get ().lookup_ast_module (resolved->get_node_id ());
if (!result.has_value ())
return false;