diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-11-22 18:20:34 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-11-22 18:20:34 +0000 |
commit | 0216a1a9a04c1efa19851aa4b049be3bcb4ff72c (patch) | |
tree | 893244e2b2d779d34877c6535a97147e969755d3 /gcc/rust/resolve | |
parent | 5a73de5ee915b9eaa24d7b04b703b8bdfea0d754 (diff) | |
download | gcc-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.
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-implitem.h | 8 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.h | 32 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve.cc | 10 |
3 files changed, 14 insertions, 36 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 |