aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-22 18:20:34 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-22 18:20:34 +0000
commit0216a1a9a04c1efa19851aa4b049be3bcb4ff72c (patch)
tree893244e2b2d779d34877c6535a97147e969755d3
parent5a73de5ee915b9eaa24d7b04b703b8bdfea0d754 (diff)
downloadgcc-0216a1a9a04c1efa19851aa4b049be3bcb4ff72c.zip
gcc-0216a1a9a04c1efa19851aa4b049be3bcb4ff72c.tar.gz
gcc-0216a1a9a04c1efa19851aa4b049be3bcb4ff72c.tar.bz2
Remove the final hack for associated types
This removes the implicit Self::associate_type paths from the name resolver these are unnessecary with the updates in the type system to resolve these.
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-implitem.h8
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.h32
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc10
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc4
4 files changed, 16 insertions, 38 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h
index e9ee75e..ef75505 100644
--- a/gcc/rust/resolve/rust-ast-resolve-implitem.h
+++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h
@@ -54,9 +54,6 @@ public:
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
});
- resolver->insert_new_definition (type.get_node_id (),
- Definition{type.get_node_id (),
- type.get_node_id ()});
}
void visit (AST::ConstantItem &constant) override
@@ -181,16 +178,13 @@ public:
{
auto path
= prefix.append (ResolveTraitItemTypeToCanonicalPath::resolve (type));
- resolver->get_name_scope ().insert (
+ resolver->get_type_scope ().insert (
path, type.get_node_id (), type.get_locus (), false,
[&] (const CanonicalPath &, NodeId, Location locus) -> void {
RichLocation r (type.get_locus ());
r.add_range (locus);
rust_error_at (r, "redefined multiple times");
});
- resolver->insert_new_definition (type.get_node_id (),
- Definition{type.get_node_id (),
- type.get_node_id ()});
}
private:
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index f60732c..a4bf261 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -453,7 +453,7 @@ public:
for (auto &impl_item : impl_block.get_impl_items ())
{
- resolve_impl_item (impl_item.get (), Self);
+ resolve_impl_item (impl_item.get ());
}
resolver->get_type_scope ().peek ()->clear_name (
@@ -584,7 +584,7 @@ public:
for (auto &impl_item : impl_block.get_impl_items ())
{
- resolve_impl_item (impl_item.get (), Self);
+ resolve_impl_item (impl_item.get ());
}
resolver->get_type_scope ().peek ()->clear_name (
@@ -646,9 +646,8 @@ public:
}
protected:
- void resolve_impl_item (AST::TraitImplItem *item, const CanonicalPath &self);
- void resolve_impl_item (AST::InherentImplItem *item,
- const CanonicalPath &self);
+ void resolve_impl_item (AST::TraitImplItem *item);
+ void resolve_impl_item (AST::InherentImplItem *item);
void resolve_extern_item (AST::ExternalItem *item);
ResolveItem () : ResolverBase (UNKNOWN_NODEID) {}
@@ -659,15 +658,15 @@ class ResolveImplItems : public ResolveItem
using Rust::Resolver::ResolveItem::visit;
public:
- static void go (AST::InherentImplItem *item, const CanonicalPath &self)
+ static void go (AST::InherentImplItem *item)
{
- ResolveImplItems resolver (self);
+ ResolveImplItems resolver;
item->accept_vis (resolver);
};
- static void go (AST::TraitImplItem *item, const CanonicalPath &self)
+ static void go (AST::TraitImplItem *item)
{
- ResolveImplItems resolver (self);
+ ResolveImplItems resolver;
item->accept_vis (resolver);
};
@@ -675,26 +674,13 @@ public:
{
ResolveItem::visit (alias);
- auto path
- = self.append (CanonicalPath::new_seg (alias.get_node_id (),
- alias.get_new_type_name ()));
- resolver->get_type_scope ().insert (
- path, alias.get_node_id (), alias.get_locus (), false,
- [&] (const CanonicalPath &, NodeId, Location locus) -> void {
- RichLocation r (alias.get_locus ());
- r.add_range (locus);
- rust_error_at (r, "redefined multiple times");
- });
-
// FIXME this stops the erronious unused decls which will be fixed later on
resolver->get_type_scope ().append_reference_for_def (alias.get_node_id (),
alias.get_node_id ());
}
private:
- ResolveImplItems (const CanonicalPath &self) : ResolveItem (), self (self) {}
-
- const CanonicalPath &self;
+ ResolveImplItems () : ResolveItem () {}
};
class ResolveExternItem : public ResolverBase
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 66553a6..39e8ee4 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -771,17 +771,15 @@ ResolveType::visit (AST::TraitObjectType &type)
// rust-ast-resolve-item.h
void
-ResolveItem::resolve_impl_item (AST::TraitImplItem *item,
- const CanonicalPath &self)
+ResolveItem::resolve_impl_item (AST::TraitImplItem *item)
{
- ResolveImplItems::go (item, self);
+ ResolveImplItems::go (item);
}
void
-ResolveItem::resolve_impl_item (AST::InherentImplItem *item,
- const CanonicalPath &self)
+ResolveItem::resolve_impl_item (AST::InherentImplItem *item)
{
- ResolveImplItems::go (item, self);
+ ResolveImplItems::go (item);
}
void
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index f1dbb6b..391ea40 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -220,7 +220,7 @@ TypeCheckType::visit (HIR::QualifiedPathInType &path)
bool fully_resolved = path.get_segments ().empty ();
if (fully_resolved)
{
- resolver->insert_resolved_name (path.get_mappings ().get_nodeid (),
+ resolver->insert_resolved_type (path.get_mappings ().get_nodeid (),
root_resolved_node_id);
context->insert_receiver (path.get_mappings ().get_hirid (), root);
return;
@@ -517,7 +517,7 @@ TypeCheckType::resolve_segments (
}
else
{
- resolver->insert_resolved_name (expr_mappings.get_nodeid (),
+ resolver->insert_resolved_type (expr_mappings.get_nodeid (),
resolved_node_id);
}