* [PATCH 1/3] Use location when lowering TupleField
2021-08-29 1:02 A few more location patches Mark Wielaard
@ 2021-08-29 1:02 ` 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 ` [PATCH 3/3] Remove GetLocusFromImplItem visitor Mark Wielaard
2 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2021-08-29 1:02 UTC (permalink / raw)
To: gcc-rust; +Cc: Mark Wielaard
---
gcc/rust/hir/rust-ast-lower-stmt.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h
index 1e72c8a2023..fdd5041d602 100644
--- a/gcc/rust/hir/rust-ast-lower-stmt.h
+++ b/gcc/rust/hir/rust-ast-lower-stmt.h
@@ -133,12 +133,10 @@ public:
mappings->get_next_localdef_id (
crate_num));
- // FIXME
- // AST::TupleField is missing Location info
- Location field_locus;
HIR::TupleField translated_field (mapping,
std::unique_ptr<HIR::Type> (type), vis,
- field_locus, field.get_outer_attrs ());
+ field.get_locus (),
+ field.get_outer_attrs ());
fields.push_back (std::move (translated_field));
return true;
});
--
2.32.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] Replace HIRItem::get_impl_locus with HirItem::get_locus
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 ` Mark Wielaard
2021-08-29 1:02 ` [PATCH 3/3] Remove GetLocusFromImplItem visitor Mark Wielaard
2 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2021-08-29 1:02 UTC (permalink / raw)
To: gcc-rust; +Cc: Mark Wielaard
HIRItem::get_impl_locus wasn't used and all subclasses already
implement get_locus.
---
gcc/rust/hir/tree/rust-hir-item.h | 6 ------
gcc/rust/hir/tree/rust-hir.h | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index 99fc91de117..7a2c2676825 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -1126,8 +1126,6 @@ public:
Location get_locus () const override final { return locus; }
- Location get_impl_locus () const final { return get_locus (); }
-
void accept_vis (HIRVisitor &vis) override;
Analysis::NodeMapping get_impl_mappings () const override
@@ -1268,8 +1266,6 @@ public:
Location get_locus () const override final { return locus; }
- Location get_impl_locus () const final { return get_locus (); }
-
void accept_vis (HIRVisitor &vis) override;
std::vector<std::unique_ptr<GenericParam> > &get_generic_params ()
@@ -2017,8 +2013,6 @@ public:
Location get_locus () const override final { return locus; }
- Location get_impl_locus () const final { return get_locus (); }
-
void accept_vis (HIRVisitor &vis) override;
Type *get_type () { return type.get (); }
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index b994d063452..8ba6308fdea 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -663,7 +663,7 @@ public:
virtual Analysis::NodeMapping get_impl_mappings () const = 0;
- virtual Location get_impl_locus () const = 0;
+ virtual Location get_locus () const = 0;
};
// A crate HIR object - holds all the data for a single compilation unit
--
2.32.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] Remove GetLocusFromImplItem visitor
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
2 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2021-08-29 1:02 UTC (permalink / raw)
To: gcc-rust; +Cc: Mark Wielaard
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
^ permalink raw reply [flat|nested] 4+ messages in thread