diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-30 10:35:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 10:35:50 +0000 |
commit | de024718701a7578225682465b2625276e55fb76 (patch) | |
tree | 8b19a2081e62c09ad03e37ab842822b93f3056c0 | |
parent | 58f2f624ef364525bd5e3e57427457ad03625102 (diff) | |
parent | 69728c595537f5a32348e0b17510338d9f2efec0 (diff) | |
download | gcc-de024718701a7578225682465b2625276e55fb76.zip gcc-de024718701a7578225682465b2625276e55fb76.tar.gz gcc-de024718701a7578225682465b2625276e55fb76.tar.bz2 |
Merge #652
652: A few more location patches r=philberty a=dkm
From Mark Wieelard: https://gcc.gnu.org/pipermail/gcc-rust/2021-August/000160.html
> Here are a couple of little patches to improve or simplify locations a
> bit
Co-authored-by: Mark Wielaard <mark@klomp.org>
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.h | 6 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 6 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.h | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h | 45 |
4 files changed, 5 insertions, 54 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h index 1e72c8a..fdd5041 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; }); diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 99fc91d..7a2c267 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 b994d06..8ba6308 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 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 ()); } |