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
--
Gcc-rust mailing list
[email protected]
https://gcc.gnu.org/mailman/listinfo/gcc-rust