aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve-toplevel.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-10-21 12:54:52 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2023-02-21 12:36:51 +0100
commit32a4659c5e405771dc8c83568b30efefc77a2031 (patch)
tree6e305de69b6f0dd11b19a24dc90a63e44b4ca912 /gcc/rust/resolve/rust-ast-resolve-toplevel.h
parent01af669357c4e7e974e85177e5d1763012bf113a (diff)
downloadgcc-32a4659c5e405771dc8c83568b30efefc77a2031.zip
gcc-32a4659c5e405771dc8c83568b30efefc77a2031.tar.gz
gcc-32a4659c5e405771dc8c83568b30efefc77a2031.tar.bz2
gccrs: Refactor name resolver to take a Rib::ItemType
This allows us to track the type of declaration that is stored within a Rib. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Add Rib argument. (ResolveExpr::resolve_closure_param): Likewise. * resolve/rust-ast-resolve-implitem.h: Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. (ResolveItem::visit): Likewise. * resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise. * resolve/rust-ast-resolve-pattern.h: Likewise. * resolve/rust-ast-resolve-stmt.h: Likewise. * resolve/rust-ast-resolve-toplevel.h: Likewise. * resolve/rust-ast-resolve-type.h: Likewise. * resolve/rust-name-resolver.cc (Rib::lookup_decl_type): Likewise. (Scope::insert): Likewise. (Resolver::insert_builtin_types): Likewise. * resolve/rust-name-resolver.h: Likewise.
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve-toplevel.h')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-toplevel.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
index 4cc5101..d751318 100644
--- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h
+++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
@@ -57,6 +57,7 @@ public:
resolver->get_name_scope ().insert (
path, module.get_node_id (), module.get_locus (), false,
+ Rib::ItemType::Module,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (module.get_locus ());
r.add_range (locus);
@@ -85,6 +86,7 @@ public:
resolver->get_type_scope ().insert (
path, alias.get_node_id (), alias.get_locus (), false,
+ Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (alias.get_locus ());
r.add_range (locus);
@@ -105,6 +107,7 @@ public:
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
+ Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (struct_decl.get_locus ());
r.add_range (locus);
@@ -125,6 +128,7 @@ public:
resolver->get_type_scope ().insert (
path, enum_decl.get_node_id (), enum_decl.get_locus (), false,
+ Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (enum_decl.get_locus ());
r.add_range (locus);
@@ -147,7 +151,7 @@ public:
auto cpath = canonical_prefix.append (decl);
resolver->get_type_scope ().insert (
- path, item.get_node_id (), item.get_locus (), false,
+ path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (item.get_locus ());
r.add_range (locus);
@@ -165,7 +169,7 @@ public:
auto cpath = canonical_prefix.append (decl);
resolver->get_type_scope ().insert (
- path, item.get_node_id (), item.get_locus (), false,
+ path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (item.get_locus ());
r.add_range (locus);
@@ -183,7 +187,7 @@ public:
auto cpath = canonical_prefix.append (decl);
resolver->get_type_scope ().insert (
- path, item.get_node_id (), item.get_locus (), false,
+ path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (item.get_locus ());
r.add_range (locus);
@@ -201,7 +205,7 @@ public:
auto cpath = canonical_prefix.append (decl);
resolver->get_type_scope ().insert (
- path, item.get_node_id (), item.get_locus (), false,
+ path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (item.get_locus ());
r.add_range (locus);
@@ -220,6 +224,7 @@ public:
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
+ Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (struct_decl.get_locus ());
r.add_range (locus);
@@ -240,6 +245,7 @@ public:
resolver->get_type_scope ().insert (
path, union_decl.get_node_id (), union_decl.get_locus (), false,
+ Rib::ItemType::Type,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (union_decl.get_locus ());
r.add_range (locus);
@@ -259,7 +265,7 @@ public:
auto cpath = canonical_prefix.append (decl);
resolver->get_name_scope ().insert (
- path, var.get_node_id (), var.get_locus (), false,
+ path, var.get_node_id (), var.get_locus (), false, Rib::ItemType::Static,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (var.get_locus ());
r.add_range (locus);
@@ -280,6 +286,7 @@ public:
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
+ Rib::ItemType::Const,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (constant.get_locus ());
r.add_range (locus);
@@ -300,6 +307,7 @@ public:
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,
+ Rib::ItemType::Function,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (function.get_locus ());
r.add_range (locus);
@@ -343,6 +351,7 @@ public:
resolver->get_name_scope ().insert (
impl_prefix, impl_block.get_node_id (), impl_block.get_locus (), false,
+ Rib::ItemType::TraitImpl,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (impl_block.get_locus ());
r.add_range (locus);
@@ -362,6 +371,7 @@ public:
resolver->get_type_scope ().insert (
path, trait.get_node_id (), trait.get_locus (), false,
+ Rib::ItemType::Trait,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (trait.get_locus ());
r.add_range (locus);
@@ -437,6 +447,7 @@ public:
resolver->get_type_scope ().insert (
decl, resolved_crate, extern_crate.get_locus (), false,
+ Rib::ItemType::ExternCrate,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (extern_crate.get_locus ());
r.add_range (locus);