public inbox for gcc-rust@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: gcc-rust@gcc.gnu.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH 3/3] Remove GetLocusFromImplItem visitor
Date: Sun, 29 Aug 2021 03:02:07 +0200	[thread overview]
Message-ID: <20210829010206.409300-4-mark@klomp.org> (raw)
In-Reply-To: <20210829010206.409300-1-mark@klomp.org>

Simply use get_locus () on the ImplItem.
Both the generics7.rs and generics8.rs testcase still pass.
---
 .../rust-hir-inherent-impl-overlap.h          | 45 +------------------
 1 file changed, 2 insertions(+), 43 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
index 134d3141d38..9a2c7fe3c07 100644
--- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
+++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
@@ -64,39 +64,6 @@ private:
   std::string &result;
 };
 
-class GetLocusFromImplItem : public TypeCheckBase
-{
-  using Rust::Resolver::TypeCheckBase::visit;
-
-public:
-  static bool Resolve (HIR::ImplItem *query, Location &locus)
-  {
-    GetLocusFromImplItem resolver (locus);
-    query->accept_vis (resolver);
-    return resolver.ok;
-  }
-
-  void visit (HIR::ConstantItem &constant) override
-  {
-    ok = true;
-    locus = constant.get_locus ();
-  }
-
-  void visit (HIR::Function &function) override
-  {
-    ok = true;
-    locus = function.get_locus ();
-  }
-
-private:
-  GetLocusFromImplItem (Location &locus)
-    : TypeCheckBase (), ok (false), locus (locus)
-  {}
-
-  bool ok;
-  Location &locus;
-};
-
 class OverlappingImplItemPass : public TypeCheckBase
 {
   using Rust::Resolver::TypeCheckBase::visit;
@@ -185,16 +152,8 @@ public:
   void collision_detected (HIR::ImplItem *query, HIR::ImplItem *dup,
 			   const std::string &name)
   {
-    Location qlocus; // query
-    bool ok = GetLocusFromImplItem::Resolve (query, qlocus);
-    rust_assert (ok);
-
-    Location dlocus; // dup
-    ok = GetLocusFromImplItem::Resolve (dup, dlocus);
-    rust_assert (ok);
-
-    RichLocation r (qlocus);
-    r.add_range (dlocus);
+    RichLocation r (query->get_locus ());
+    r.add_range (dup->get_locus ());
     rust_error_at (r, "duplicate definitions with name %s", name.c_str ());
   }
 
-- 
2.32.0


      parent reply	other threads:[~2021-08-29  1:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-29  1:02 A few more location patches Mark Wielaard
2021-08-29  1:02 ` [PATCH 1/3] Use location when lowering TupleField Mark Wielaard
2021-08-29  1:02 ` [PATCH 2/3] Replace HIRItem::get_impl_locus with HirItem::get_locus Mark Wielaard
2021-08-29  1:02 ` Mark Wielaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210829010206.409300-4-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=gcc-rust@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).