aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-08-29 01:55:27 +0200
committerMark Wielaard <mark@klomp.org>2021-08-29 02:01:59 +0200
commit69728c595537f5a32348e0b17510338d9f2efec0 (patch)
tree8b19a2081e62c09ad03e37ab842822b93f3056c0 /gcc
parentf16e3af9ad774cbdbb534fd68066582aefc6bf80 (diff)
downloadgcc-69728c595537f5a32348e0b17510338d9f2efec0.zip
gcc-69728c595537f5a32348e0b17510338d9f2efec0.tar.gz
gcc-69728c595537f5a32348e0b17510338d9f2efec0.tar.bz2
Remove GetLocusFromImplItem visitor
Simply use get_locus () on the ImplItem. Both the generics7.rs and generics8.rs testcase still pass.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h45
1 files 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 134d314..9a2c7fe 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 ());
}