From: arthur.cohen@embecosm.com
To: gcc-patches@gcc.gnu.org
Cc: gcc-rust@gcc.gnu.org,
Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Subject: [committed 62/88] gccrs: typecheck: Refactor rust-hir-trait-reference.h
Date: Wed, 5 Apr 2023 16:03:46 +0200 [thread overview]
Message-ID: <20230405140411.3016563-63-arthur.cohen@embecosm.com> (raw)
In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com>
From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Move function body to their own cc file instead of keeping them in the
header file.
gcc/rust/ChangeLog:
* Make-lang.in: Add `rust-hir-trait-reference.o`.
* typecheck/rust-hir-trait-reference.h: Remove multiple function body.
* typecheck/rust-hir-trait-reference.cc: Add multiple function body.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
---
gcc/rust/Make-lang.in | 1 +
.../typecheck/rust-hir-trait-reference.cc | 463 ++++++++++++++++++
gcc/rust/typecheck/rust-hir-trait-reference.h | 343 ++-----------
3 files changed, 510 insertions(+), 297 deletions(-)
create mode 100644 gcc/rust/typecheck/rust-hir-trait-reference.cc
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index d9bc40945c3..09bbe450bd5 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -123,6 +123,7 @@ GRS_OBJS = \
rust/rust-tyty-bounds.o \
rust/rust-hir-type-check-util.o \
rust/rust-hir-trait-resolve.o \
+ rust/rust-hir-trait-reference.o \
rust/rust-hir-type-check-item.o \
rust/rust-hir-type-check-type.o \
rust/rust-hir-type-check-struct.o \
diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.cc b/gcc/rust/typecheck/rust-hir-trait-reference.cc
new file mode 100644
index 00000000000..651c55abc82
--- /dev/null
+++ b/gcc/rust/typecheck/rust-hir-trait-reference.cc
@@ -0,0 +1,463 @@
+// Copyright (C) 2020-2022 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include "rust-hir-trait-reference.h"
+
+namespace Rust {
+namespace Resolver {
+
+std::string
+TraitItemReference::as_string () const
+{
+ return "(" + trait_item_type_as_string (type) + " " + identifier + " " + ")";
+}
+
+bool
+TraitItemReference::is_error () const
+{
+ return type == ERROR;
+}
+
+bool
+TraitItemReference::is_optional () const
+{
+ return optional_flag;
+};
+
+std::string
+TraitItemReference::get_identifier () const
+{
+ return identifier;
+}
+
+TraitItemReference::TraitItemType
+TraitItemReference::get_trait_item_type () const
+{
+ return type;
+}
+
+HIR::TraitItem *
+TraitItemReference::get_hir_trait_item () const
+{
+ return hir_trait_item;
+}
+
+Location
+TraitItemReference::get_locus () const
+{
+ return locus;
+}
+
+const Analysis::NodeMapping
+TraitItemReference::get_mappings () const
+{
+ return hir_trait_item->get_mappings ();
+}
+
+TyTy::BaseType *
+TraitItemReference::get_tyty () const
+{
+ rust_assert (hir_trait_item != nullptr);
+
+ switch (type)
+ {
+ case CONST:
+ return get_type_from_constant (
+ static_cast</*const*/ HIR::TraitItemConst &> (*hir_trait_item));
+ break;
+
+ case TYPE:
+ return get_type_from_typealias (
+ static_cast</*const*/ HIR::TraitItemType &> (*hir_trait_item));
+
+ case FN:
+ return get_type_from_fn (
+ static_cast</*const*/ HIR::TraitItemFunc &> (*hir_trait_item));
+ break;
+
+ default:
+ return get_error ();
+ }
+
+ gcc_unreachable ();
+ return get_error ();
+}
+
+TyTy::ErrorType *
+TraitItemReference::get_error () const
+{
+ return new TyTy::ErrorType (get_mappings ().get_hirid ());
+}
+
+TraitReference::TraitReference (
+ const HIR::Trait *hir_trait_ref, std::vector<TraitItemReference> item_refs,
+ std::vector<const TraitReference *> super_traits,
+ std::vector<TyTy::SubstitutionParamMapping> substs)
+ : hir_trait_ref (hir_trait_ref), item_refs (item_refs),
+ super_traits (super_traits)
+{
+ trait_substs.clear ();
+ trait_substs.reserve (substs.size ());
+ for (const auto &p : substs)
+ trait_substs.push_back (p.clone ());
+}
+
+TraitReference::TraitReference (TraitReference const &other)
+ : hir_trait_ref (other.hir_trait_ref), item_refs (other.item_refs),
+ super_traits (other.super_traits)
+{
+ trait_substs.clear ();
+ trait_substs.reserve (other.trait_substs.size ());
+ for (const auto &p : other.trait_substs)
+ trait_substs.push_back (p.clone ());
+}
+
+TraitReference &
+TraitReference::operator= (TraitReference const &other)
+{
+ hir_trait_ref = other.hir_trait_ref;
+ item_refs = other.item_refs;
+ super_traits = other.super_traits;
+
+ trait_substs.clear ();
+ trait_substs.reserve (other.trait_substs.size ());
+ for (const auto &p : other.trait_substs)
+ trait_substs.push_back (p.clone ());
+
+ return *this;
+}
+
+bool
+TraitReference::is_error () const
+{
+ return hir_trait_ref == nullptr;
+}
+
+Location
+TraitReference::get_locus () const
+{
+ return hir_trait_ref->get_locus ();
+}
+
+std::string
+TraitReference::get_name () const
+{
+ rust_assert (!is_error ());
+ return hir_trait_ref->get_name ();
+}
+
+std::string
+TraitReference::as_string () const
+{
+ if (is_error ())
+ return "<trait-ref-error-node>";
+
+ std::string item_buf;
+ for (auto &item : item_refs)
+ {
+ item_buf += item.as_string () + ", ";
+ }
+ return "HIR Trait: " + get_name () + "->"
+ + hir_trait_ref->get_mappings ().as_string () + " [" + item_buf + "]";
+}
+
+const HIR::Trait *
+TraitReference::get_hir_trait_ref () const
+{
+ return hir_trait_ref;
+}
+
+const Analysis::NodeMapping &
+TraitReference::get_mappings () const
+{
+ return hir_trait_ref->get_mappings ();
+}
+
+DefId
+TraitReference::get_defid () const
+{
+ return get_mappings ().get_defid ();
+}
+
+bool
+TraitReference::lookup_hir_trait_item (const HIR::TraitItem &item,
+ TraitItemReference **ref)
+{
+ return lookup_trait_item (item.trait_identifier (), ref);
+}
+
+bool
+TraitReference::lookup_trait_item (const std::string &ident,
+ TraitItemReference **ref)
+{
+ for (auto &item : item_refs)
+ {
+ if (ident.compare (item.get_identifier ()) == 0)
+ {
+ *ref = &item;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+TraitReference::lookup_trait_item_by_type (
+ const std::string &ident, TraitItemReference::TraitItemType type,
+ TraitItemReference **ref)
+{
+ for (auto &item : item_refs)
+ {
+ if (item.get_trait_item_type () != type)
+ continue;
+
+ if (ident.compare (item.get_identifier ()) == 0)
+ {
+ *ref = &item;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+TraitReference::lookup_trait_item_by_type (
+ const std::string &ident, TraitItemReference::TraitItemType type,
+ const TraitItemReference **ref) const
+{
+ for (auto &item : item_refs)
+ {
+ if (item.get_trait_item_type () != type)
+ continue;
+
+ if (ident.compare (item.get_identifier ()) == 0)
+ {
+ *ref = &item;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+TraitReference::lookup_hir_trait_item (const HIR::TraitItem &item,
+ const TraitItemReference **ref) const
+{
+ return lookup_trait_item (item.trait_identifier (), ref);
+}
+
+bool
+TraitReference::lookup_trait_item (const std::string &ident,
+ const TraitItemReference **ref) const
+{
+ for (auto &item : item_refs)
+ {
+ if (ident.compare (item.get_identifier ()) == 0)
+ {
+ *ref = &item;
+ return true;
+ }
+ }
+
+ // lookup super traits
+ for (const auto &super_trait : super_traits)
+ {
+ bool found = super_trait->lookup_trait_item (ident, ref);
+ if (found)
+ return true;
+ }
+
+ return false;
+}
+
+const TraitItemReference *
+TraitReference::lookup_trait_item (const std::string &ident,
+ TraitItemReference::TraitItemType type) const
+{
+ for (auto &item : item_refs)
+ {
+ if (item.get_trait_item_type () != type)
+ continue;
+
+ if (ident.compare (item.get_identifier ()) == 0)
+ return &item;
+ }
+
+ // lookup super traits
+ for (const auto &super_trait : super_traits)
+ {
+ const TraitItemReference *res
+ = super_trait->lookup_trait_item (ident, type);
+ if (!res->is_error ())
+ return res;
+ }
+
+ return &TraitItemReference::error_node ();
+}
+
+size_t
+TraitReference::size () const
+{
+ return item_refs.size ();
+}
+
+const std::vector<TraitItemReference> &
+TraitReference::get_trait_items () const
+{
+ return item_refs;
+}
+
+void
+TraitReference::get_trait_items_and_supers (
+ std::vector<const TraitItemReference *> &result) const
+{
+ for (const auto &item : item_refs)
+ result.push_back (&item);
+
+ for (const auto &super_trait : super_traits)
+ super_trait->get_trait_items_and_supers (result);
+}
+
+void
+TraitReference::on_resolved ()
+{
+ for (auto &item : item_refs)
+ {
+ item.on_resolved ();
+ }
+}
+
+void
+TraitReference::clear_associated_types ()
+{
+ for (auto &item : item_refs)
+ {
+ bool is_assoc_type = item.get_trait_item_type ()
+ == TraitItemReference::TraitItemType::TYPE;
+ if (is_assoc_type)
+ item.associated_type_reset ();
+ }
+}
+
+bool
+TraitReference::is_equal (const TraitReference &other) const
+{
+ DefId this_id = get_mappings ().get_defid ();
+ DefId other_id = other.get_mappings ().get_defid ();
+ return this_id == other_id;
+}
+
+const std::vector<const TraitReference *>
+TraitReference::get_super_traits () const
+{
+ return super_traits;
+}
+
+bool
+TraitReference::is_object_safe (bool emit_error, Location locus) const
+{
+ // https: // doc.rust-lang.org/reference/items/traits.html#object-safety
+ std::vector<const TraitReference *> non_object_super_traits;
+ for (auto &item : super_traits)
+ {
+ if (!item->is_object_safe (false, Location ()))
+ non_object_super_traits.push_back (item);
+ }
+
+ std::vector<const Resolver::TraitItemReference *> non_object_safe_items;
+ for (auto &item : get_trait_items ())
+ {
+ if (!item.is_object_safe ())
+ non_object_safe_items.push_back (&item);
+ }
+
+ bool is_safe
+ = non_object_super_traits.empty () && non_object_safe_items.empty ();
+ if (emit_error && !is_safe)
+ {
+ RichLocation r (locus);
+ for (auto &item : non_object_super_traits)
+ r.add_range (item->get_locus ());
+ for (auto &item : non_object_safe_items)
+ r.add_range (item->get_locus ());
+
+ rust_error_at (r, "trait bound is not object safe");
+ }
+
+ return is_safe;
+}
+
+bool
+TraitReference::trait_has_generics () const
+{
+ return !trait_substs.empty ();
+}
+
+std::vector<TyTy::SubstitutionParamMapping>
+TraitReference::get_trait_substs () const
+{
+ return trait_substs;
+}
+
+bool
+TraitReference::satisfies_bound (const TraitReference &reference) const
+{
+ if (is_equal (reference))
+ return true;
+
+ for (const auto &super_trait : super_traits)
+ {
+ if (super_trait->satisfies_bound (reference))
+ return true;
+ }
+
+ return false;
+}
+
+AssociatedImplTrait::AssociatedImplTrait (TraitReference *trait,
+ HIR::ImplBlock *impl,
+ TyTy::BaseType *self,
+ Resolver::TypeCheckContext *context)
+ : trait (trait), impl (impl), self (self), context (context)
+{}
+
+TraitReference *
+AssociatedImplTrait::get_trait ()
+{
+ return trait;
+}
+
+HIR::ImplBlock *
+AssociatedImplTrait::get_impl_block ()
+{
+ return impl;
+}
+
+TyTy::BaseType *
+AssociatedImplTrait::get_self ()
+{
+ return self;
+}
+const TyTy::BaseType *
+AssociatedImplTrait::get_self () const
+{
+ return self;
+}
+
+} // namespace Resolver
+} // namespace Rust
diff --git a/gcc/rust/typecheck/rust-hir-trait-reference.h b/gcc/rust/typecheck/rust-hir-trait-reference.h
index adb63b468d1..f3703efcced 100644
--- a/gcc/rust/typecheck/rust-hir-trait-reference.h
+++ b/gcc/rust/typecheck/rust-hir-trait-reference.h
@@ -20,8 +20,8 @@
#define RUST_HIR_TRAIT_REF_H
#include "rust-hir-full.h"
-#include "rust-tyty-visitor.h"
#include "rust-hir-type-check-util.h"
+#include "rust-tyty-visitor.h"
namespace Rust {
namespace Resolver {
@@ -61,13 +61,9 @@ public:
return error;
}
- bool is_error () const { return type == ERROR; }
+ bool is_error () const;
- std::string as_string () const
- {
- return "(" + trait_item_type_as_string (type) + " " + identifier + " "
- + ")";
- }
+ std::string as_string () const;
static std::string trait_item_type_as_string (TraitItemType ty)
{
@@ -85,53 +81,24 @@ public:
return "ERROR";
}
- bool is_optional () const { return optional_flag; }
-
- std::string get_identifier () const { return identifier; }
-
- TraitItemType get_trait_item_type () const { return type; }
-
- HIR::TraitItem *get_hir_trait_item () const { return hir_trait_item; }
+ bool is_optional () const;
- Location get_locus () const { return locus; }
+ std::string get_identifier () const;
- const Analysis::NodeMapping get_mappings () const
- {
- return hir_trait_item->get_mappings ();
- }
+ TraitItemType get_trait_item_type () const;
- TyTy::BaseType *get_tyty () const
- {
- rust_assert (hir_trait_item != nullptr);
+ HIR::TraitItem *get_hir_trait_item () const;
- switch (type)
- {
- case CONST:
- return get_type_from_constant (
- static_cast</*const*/ HIR::TraitItemConst &> (*hir_trait_item));
- break;
+ Location get_locus () const;
- case TYPE:
- return get_type_from_typealias (
- static_cast</*const*/ HIR::TraitItemType &> (*hir_trait_item));
+ const Analysis::NodeMapping get_mappings () const;
- case FN:
- return get_type_from_fn (
- static_cast</*const*/ HIR::TraitItemFunc &> (*hir_trait_item));
- break;
-
- default:
- return get_error ();
- }
-
- gcc_unreachable ();
- return get_error ();
- }
+ TyTy::BaseType *get_tyty () const;
Analysis::NodeMapping get_parent_trait_mappings () const;
- // this is called when the trait is completed resolution and gives the items a
- // chance to run their specific type resolution passes. If we call their
+ // this is called when the trait is completed resolution and gives the items
+ // a chance to run their specific type resolution passes. If we call their
// resolution on construction it can lead to a case where the trait being
// resolved recursively trying to resolve the trait itself infinitely since
// the trait will not be stored in its own map yet
@@ -144,10 +111,7 @@ public:
bool is_object_safe () const;
private:
- TyTy::ErrorType *get_error () const
- {
- return new TyTy::ErrorType (get_mappings ().get_hirid ());
- }
+ TyTy::ErrorType *get_error () const;
TyTy::BaseType *get_type_from_typealias (/*const*/
HIR::TraitItemType &type) const;
@@ -182,39 +146,11 @@ public:
TraitReference (const HIR::Trait *hir_trait_ref,
std::vector<TraitItemReference> item_refs,
std::vector<const TraitReference *> super_traits,
- std::vector<TyTy::SubstitutionParamMapping> substs)
- : hir_trait_ref (hir_trait_ref), item_refs (item_refs),
- super_traits (super_traits)
- {
- trait_substs.clear ();
- trait_substs.reserve (substs.size ());
- for (const auto &p : substs)
- trait_substs.push_back (p.clone ());
- }
-
- TraitReference (TraitReference const &other)
- : hir_trait_ref (other.hir_trait_ref), item_refs (other.item_refs),
- super_traits (other.super_traits)
- {
- trait_substs.clear ();
- trait_substs.reserve (other.trait_substs.size ());
- for (const auto &p : other.trait_substs)
- trait_substs.push_back (p.clone ());
- }
-
- TraitReference &operator= (TraitReference const &other)
- {
- hir_trait_ref = other.hir_trait_ref;
- item_refs = other.item_refs;
- super_traits = other.super_traits;
+ std::vector<TyTy::SubstitutionParamMapping> substs);
- trait_substs.clear ();
- trait_substs.reserve (other.trait_substs.size ());
- for (const auto &p : other.trait_substs)
- trait_substs.push_back (p.clone ());
+ TraitReference (TraitReference const &other);
- return *this;
- }
+ TraitReference &operator= (TraitReference const &other);
TraitReference (TraitReference &&other) = default;
TraitReference &operator= (TraitReference &&other) = default;
@@ -224,7 +160,7 @@ public:
return TraitReference (nullptr, {}, {}, {});
}
- bool is_error () const { return hir_trait_ref == nullptr; }
+ bool is_error () const;
static TraitReference &error_node ()
{
@@ -232,248 +168,63 @@ public:
return trait_error_node;
}
- Location get_locus () const { return hir_trait_ref->get_locus (); }
+ Location get_locus () const;
- std::string get_name () const
- {
- rust_assert (!is_error ());
- return hir_trait_ref->get_name ();
- }
+ std::string get_name () const;
- std::string as_string () const
- {
- if (is_error ())
- return "<trait-ref-error-node>";
-
- std::string item_buf;
- for (auto &item : item_refs)
- {
- item_buf += item.as_string () + ", ";
- }
- return "HIR Trait: " + get_name () + "->"
- + hir_trait_ref->get_mappings ().as_string () + " [" + item_buf
- + "]";
- }
+ std::string as_string () const;
- const HIR::Trait *get_hir_trait_ref () const { return hir_trait_ref; }
+ const HIR::Trait *get_hir_trait_ref () const;
- const Analysis::NodeMapping &get_mappings () const
- {
- return hir_trait_ref->get_mappings ();
- }
+ const Analysis::NodeMapping &get_mappings () const;
- DefId get_defid () const { return get_mappings ().get_defid (); }
+ DefId get_defid () const;
bool lookup_hir_trait_item (const HIR::TraitItem &item,
- TraitItemReference **ref)
- {
- return lookup_trait_item (item.trait_identifier (), ref);
- }
+ TraitItemReference **ref);
- bool lookup_trait_item (const std::string &ident, TraitItemReference **ref)
- {
- for (auto &item : item_refs)
- {
- if (ident.compare (item.get_identifier ()) == 0)
- {
- *ref = &item;
- return true;
- }
- }
- return false;
- }
+ bool lookup_trait_item (const std::string &ident, TraitItemReference **ref);
bool lookup_trait_item_by_type (const std::string &ident,
TraitItemReference::TraitItemType type,
- TraitItemReference **ref)
- {
- for (auto &item : item_refs)
- {
- if (item.get_trait_item_type () != type)
- continue;
-
- if (ident.compare (item.get_identifier ()) == 0)
- {
- *ref = &item;
- return true;
- }
- }
- return false;
- }
+ TraitItemReference **ref);
bool lookup_trait_item_by_type (const std::string &ident,
TraitItemReference::TraitItemType type,
- const TraitItemReference **ref) const
- {
- for (auto &item : item_refs)
- {
- if (item.get_trait_item_type () != type)
- continue;
-
- if (ident.compare (item.get_identifier ()) == 0)
- {
- *ref = &item;
- return true;
- }
- }
- return false;
- }
+ const TraitItemReference **ref) const;
bool lookup_hir_trait_item (const HIR::TraitItem &item,
- const TraitItemReference **ref) const
- {
- return lookup_trait_item (item.trait_identifier (), ref);
- }
+ const TraitItemReference **ref) const;
bool lookup_trait_item (const std::string &ident,
- const TraitItemReference **ref) const
- {
- for (auto &item : item_refs)
- {
- if (ident.compare (item.get_identifier ()) == 0)
- {
- *ref = &item;
- return true;
- }
- }
-
- // lookup super traits
- for (const auto &super_trait : super_traits)
- {
- bool found = super_trait->lookup_trait_item (ident, ref);
- if (found)
- return true;
- }
-
- return false;
- }
+ const TraitItemReference **ref) const;
const TraitItemReference *
lookup_trait_item (const std::string &ident,
- TraitItemReference::TraitItemType type) const
- {
- for (auto &item : item_refs)
- {
- if (item.get_trait_item_type () != type)
- continue;
+ TraitItemReference::TraitItemType type) const;
- if (ident.compare (item.get_identifier ()) == 0)
- return &item;
- }
+ size_t size () const;
- // lookup super traits
- for (const auto &super_trait : super_traits)
- {
- const TraitItemReference *res
- = super_trait->lookup_trait_item (ident, type);
- if (!res->is_error ())
- return res;
- }
-
- return &TraitItemReference::error_node ();
- }
-
- size_t size () const { return item_refs.size (); }
-
- const std::vector<TraitItemReference> &get_trait_items () const
- {
- return item_refs;
- }
+ const std::vector<TraitItemReference> &get_trait_items () const;
void get_trait_items_and_supers (
- std::vector<const TraitItemReference *> &result) const
- {
- for (const auto &item : item_refs)
- result.push_back (&item);
-
- for (const auto &super_trait : super_traits)
- super_trait->get_trait_items_and_supers (result);
- }
-
- void on_resolved ()
- {
- for (auto &item : item_refs)
- {
- item.on_resolved ();
- }
- }
-
- void clear_associated_types ()
- {
- for (auto &item : item_refs)
- {
- bool is_assoc_type = item.get_trait_item_type ()
- == TraitItemReference::TraitItemType::TYPE;
- if (is_assoc_type)
- item.associated_type_reset ();
- }
- }
-
- bool is_equal (const TraitReference &other) const
- {
- DefId this_id = get_mappings ().get_defid ();
- DefId other_id = other.get_mappings ().get_defid ();
- return this_id == other_id;
- }
-
- const std::vector<const TraitReference *> get_super_traits () const
- {
- return super_traits;
- }
-
- bool is_object_safe (bool emit_error, Location locus) const
- {
- // https: // doc.rust-lang.org/reference/items/traits.html#object-safety
- std::vector<const TraitReference *> non_object_super_traits;
- for (auto &item : super_traits)
- {
- if (!item->is_object_safe (false, Location ()))
- non_object_super_traits.push_back (item);
- }
+ std::vector<const TraitItemReference *> &result) const;
- std::vector<const Resolver::TraitItemReference *> non_object_safe_items;
- for (auto &item : get_trait_items ())
- {
- if (!item.is_object_safe ())
- non_object_safe_items.push_back (&item);
- }
+ void on_resolved ();
- bool is_safe
- = non_object_super_traits.empty () && non_object_safe_items.empty ();
- if (emit_error && !is_safe)
- {
- RichLocation r (locus);
- for (auto &item : non_object_super_traits)
- r.add_range (item->get_locus ());
- for (auto &item : non_object_safe_items)
- r.add_range (item->get_locus ());
+ void clear_associated_types ();
- rust_error_at (r, "trait bound is not object safe");
- }
+ bool is_equal (const TraitReference &other) const;
- return is_safe;
- }
+ const std::vector<const TraitReference *> get_super_traits () const;
- bool trait_has_generics () const { return !trait_substs.empty (); }
+ bool is_object_safe (bool emit_error, Location locus) const;
- std::vector<TyTy::SubstitutionParamMapping> get_trait_substs () const
- {
- return trait_substs;
- }
-
- bool satisfies_bound (const TraitReference &reference) const
- {
- if (is_equal (reference))
- return true;
+ bool trait_has_generics () const;
- for (const auto &super_trait : super_traits)
- {
- if (super_trait->satisfies_bound (reference))
- return true;
- }
+ std::vector<TyTy::SubstitutionParamMapping> get_trait_substs () const;
- return false;
- }
+ bool satisfies_bound (const TraitReference &reference) const;
private:
const HIR::Trait *hir_trait_ref;
@@ -487,16 +238,14 @@ class AssociatedImplTrait
public:
AssociatedImplTrait (TraitReference *trait, HIR::ImplBlock *impl,
TyTy::BaseType *self,
- Resolver::TypeCheckContext *context)
- : trait (trait), impl (impl), self (self), context (context)
- {}
+ Resolver::TypeCheckContext *context);
- TraitReference *get_trait () { return trait; }
+ TraitReference *get_trait ();
- HIR::ImplBlock *get_impl_block () { return impl; }
+ HIR::ImplBlock *get_impl_block ();
- TyTy::BaseType *get_self () { return self; }
- const TyTy::BaseType *get_self () const { return self; }
+ TyTy::BaseType *get_self ();
+ const TyTy::BaseType *get_self () const;
TyTy::BaseType *
setup_associated_types (const TyTy::BaseType *self,
--
2.40.0
next prev parent reply other threads:[~2023-04-05 14:06 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 14:02 Rust front-end update 2023-04-05 arthur.cohen
2023-04-05 14:02 ` [committed 01/88] gccrs: fatal_error_flag: Fix typo in error message arthur.cohen
2023-04-05 14:02 ` [committed 02/88] gccrs: unsafe: check use of `target_feature` attribute arthur.cohen
2023-04-05 14:02 ` [committed 03/88] gccrs: Check for mutable references in const functions arthur.cohen
2023-04-05 14:02 ` [committed 04/88] gccrs: rust: add bound parsing in parse_generic_arg arthur.cohen
2023-04-05 14:02 ` [committed 05/88] gccrs: Implement declarative macro 2.0 parser arthur.cohen
2023-04-05 14:02 ` [committed 06/88] gccrs: Add name resolution to generic argument associated item bindings arthur.cohen
2023-04-05 14:02 ` [committed 07/88] gccrs: Support associated type bound arguments arthur.cohen
2023-04-05 14:02 ` [committed 08/88] gccrs: Reuse TypeCheckPattern on LetStmt's arthur.cohen
2023-04-05 14:02 ` [committed 09/88] gccrs: Add get_locus function for abstract class MetaItemInner arthur.cohen
2023-04-05 14:02 ` [committed 10/88] gccrs: diagnostics: Add underline for tokens in diagnostics arthur.cohen
2023-04-05 14:02 ` [committed 11/88] gccrs: Change how CompileVarDecl outputs Bvariable's arthur.cohen
2023-04-05 14:02 ` [committed 12/88] gccrs: testsuite: Handle Windows carriage returns properly arthur.cohen
2023-04-05 14:02 ` [committed 13/88] gccrs: Support GroupedPattern during name resolution arthur.cohen
2023-04-05 14:02 ` [committed 14/88] gccrs: Do not crash on empty macros expand. Fixes #1712 arthur.cohen
2023-04-05 14:02 ` [committed 15/88] gccrs: Add HIR lowering for GroupedPattern arthur.cohen
2023-04-05 14:03 ` [committed 16/88] gccrs: Add get_item method for HIR::GroupedPattern arthur.cohen
2023-04-05 14:03 ` [committed 17/88] gccrs: Add type resolution for grouped patterns arthur.cohen
2023-04-05 14:03 ` [committed 18/88] gccrs: Added missing GroupedPattern visitors for code generation arthur.cohen
2023-04-05 14:03 ` [committed 19/88] gccrs: Rename file rust-ast-full-test.cc to rust-ast.cc arthur.cohen
2023-04-05 14:03 ` [committed 20/88] gccrs: moved operator.h to util/rust-operators.h arthur.cohen
2023-04-05 14:03 ` [committed 21/88] gccrs: fixed compiler error message on wildcard pattern within expression arthur.cohen
2023-04-05 14:03 ` [committed 22/88] gccrs: fixed indentations in AST pretty expanded dump of trait arthur.cohen
2023-04-05 14:03 ` [committed 23/88] gccrs: macro: Allow builtin `MacroInvocation`s within the AST arthur.cohen
2023-04-05 14:03 ` [committed 24/88] gccrs: Create and use CompilePatternLet visitor for compiling let statments arthur.cohen
2023-04-05 14:03 ` [committed 25/88] gccrs: parser: Allow parsing multiple reference types arthur.cohen
2023-04-05 14:03 ` [committed 26/88] gccrs: Move rust-buffered-queue.h to util folder #1766 arthur.cohen
2023-04-05 14:03 ` [committed 27/88] gccrs: Improve GroupedPattern lowering arthur.cohen
2023-04-05 14:03 ` [committed 28/88] gccrs: Remove HIR::GroupedPattern arthur.cohen
2023-04-05 14:03 ` [committed 29/88] gccrs: Optimize HIR::ReferencePattern arthur.cohen
2023-04-05 14:03 ` [committed 30/88] gccrs: Implement lowering ReferencePattern from AST to HIR arthur.cohen
2023-04-05 14:03 ` [committed 31/88] gccrs: parser: Improve parsing of complex generic arguments arthur.cohen
2023-04-05 14:03 ` [committed 32/88] gccrs: parser: Fix parsing of closure param list arthur.cohen
2023-04-05 14:03 ` [committed 33/88] gccrs: Add support for feature check arthur.cohen
2023-04-05 14:03 ` [committed 34/88] gccrs: Removed comment copy-pasted from gcc/tree.def arthur.cohen
2023-04-05 14:03 ` [committed 35/88] gccrs: Add another test case for passing associated type-bounds arthur.cohen
2023-04-05 14:03 ` [committed 36/88] gccrs: Move TypePredicateItem impl out of the header arthur.cohen
2023-04-05 14:03 ` [committed 37/88] gccrs: Refactor TyVar and TypeBoundPredicates arthur.cohen
2023-04-05 14:03 ` [committed 38/88] gccrs: Refactor SubstitutionRef base class into its own CC file arthur.cohen
2023-04-05 14:03 ` [committed 39/88] gccrs: Refactor all substitution mapper code implementation " arthur.cohen
2023-04-05 14:03 ` [committed 40/88] gccrs: Refactor BaseType, InferType and ErrorType impl into cc file arthur.cohen
2023-04-05 14:03 ` [committed 41/88] gccrs: Refactor PathProbe " arthur.cohen
2023-04-05 14:03 ` [committed 42/88] gccrs: Refactor PathProbeType code into CC file arthur.cohen
2023-04-05 14:03 ` [committed 43/88] gccrs: Refactor all code out of the rust-tyty.h header arthur.cohen
2023-04-05 14:03 ` [committed 44/88] gccrs: Rename rust-tyctx.cc to rust-typecheck-context.cc arthur.cohen
2023-04-05 14:03 ` [committed 45/88] gccrs: Rename header rust-hir-trait-ref.h to rust-hir-trait-reference.h arthur.cohen
2023-04-05 14:03 ` [committed 46/88] gccrs: Refactor handle_substitutions to take a reference arthur.cohen
2023-04-05 14:03 ` [committed 47/88] gccrs: Clear the substitution callbacks when copying ArgumentMappings arthur.cohen
2023-04-05 14:03 ` [committed 48/88] gccrs: Add missing param subst callback arthur.cohen
2023-04-05 14:03 ` [committed 49/88] gccrs: Remove monomorphization hack to setup possible associated types arthur.cohen
2023-04-05 14:03 ` [committed 50/88] gccrs: Refactor the type unification code arthur.cohen
2023-04-05 14:03 ` [committed 51/88] gccrs: Fix nullptr dereference arthur.cohen
2023-04-05 14:03 ` [committed 52/88] gccrs: Add missing Sized, Copy and Clone lang item mappings arthur.cohen
2023-04-05 14:03 ` [committed 53/88] gccrs: Fix higher ranked trait bounds computation of self arthur.cohen
2023-04-05 14:03 ` [committed 54/88] gccrs: Remove bad error message on checking function arguments arthur.cohen
2023-04-05 14:03 ` [committed 55/88] gccrs: Add general TypeBounds checks arthur.cohen
2023-04-05 14:03 ` [committed 56/88] gccrs: Add support for TuplePattern in let statements arthur.cohen
2023-04-05 14:03 ` [committed 57/88] gccrs: rust-item: include rust-expr.h arthur.cohen
2023-04-05 14:03 ` [committed 58/88] gccrs: parser: Expose parse_macro_invocation as public API arthur.cohen
2023-04-05 14:03 ` [committed 59/88] gccrs: expansion: Add `get_token_slice` to `MacroInvocLexer` class arthur.cohen
2023-04-05 14:03 ` [committed 60/88] gccrs: macros: Perform macro expansion in a fixed-point fashion arthur.cohen
2023-04-05 14:03 ` [committed 61/88] gccrs: expander: Add documentation for `expand_eager_invocations` arthur.cohen
2023-04-05 14:03 ` arthur.cohen [this message]
2023-04-05 14:03 ` [committed 63/88] gccrs: cli: Update safety warning message arthur.cohen
2023-04-05 14:03 ` [committed 64/88] gccrs: Update copyright years arthur.cohen
2023-04-05 14:03 ` [committed 65/88] gccrs: Add feature gate for "rust-intrinsic" arthur.cohen
2023-04-05 14:03 ` [committed 66/88] gccrs: Add variadic argument type checking arthur.cohen
2023-04-05 14:03 ` [committed 67/88] gccrs: Add test arthur.cohen
2023-04-05 14:03 ` [committed 68/88] gccrs: Simplify WildcardPattern let statement handling arthur.cohen
2023-04-05 14:03 ` [committed 69/88] gccrs: lex: Prevent directories in RAIIFile arthur.cohen
2023-04-05 14:03 ` [committed 70/88] gccrs: testsuite: Add empty string macro test arthur.cohen
2023-04-05 14:03 ` [committed 71/88] gccrs: Add support for parsing empty tuple patterns arthur.cohen
2023-04-05 14:03 ` [committed 72/88] gccrs: Implemented UTF-8 checking for include_str!() arthur.cohen
2023-04-05 14:03 ` [committed 73/88] gccrs: Extract query_type from TypeCheckBase to be a simple extern arthur.cohen
2023-04-05 14:03 ` [committed 74/88] gccrs: Add new virtual function HIR::ImplItem::get_impl_item_name arthur.cohen
2023-04-05 14:03 ` [committed 75/88] gccrs: Support for Sized builtin marker trait arthur.cohen
2023-04-05 14:04 ` [committed 76/88] gccrs: Fix regression in testcase arthur.cohen
2023-04-05 14:04 ` [committed 77/88] gccrs: Add trailing newline arthur.cohen
2023-04-05 14:04 ` [committed 78/88] gccrs: builtins: Return empty list of tokens instead of nullptr arthur.cohen
2023-04-05 14:04 ` [committed 79/88] gccrs: Fix formatting arthur.cohen
2023-04-05 14:04 ` [committed 80/88] gccrs: Add AST::AltPattern class arthur.cohen
2023-04-05 14:04 ` [committed 81/88] gccrs: Fix up DejaGnu directives in 'rust/compile/issue-1830_{bytes,str}.rs' test cases [#1838] arthur.cohen
2023-04-05 14:04 ` [committed 82/88] gccrs: rename rust-hir-full-tests.cc arthur.cohen
2023-04-05 14:04 ` [committed 83/88] gccrs: add test case to show our query-type system is working arthur.cohen
2023-04-05 14:04 ` [committed 84/88] gccrs: ast: Refactor TraitItem to keep Location info arthur.cohen
2023-04-05 14:04 ` [committed 85/88] gccrs: diagnostic: Refactor Error class arthur.cohen
2023-04-05 14:04 ` [committed 86/88] gccrs: Added AST Node AST::InlineAsm arthur.cohen
2023-04-05 14:04 ` [committed 87/88] gccrs: Address unsafe with/without block handling ambiguity arthur.cohen
2023-04-05 14:04 ` [committed 88/88] gccrs: Fix issue with parsing unsafe block expression statements arthur.cohen
2023-04-06 7:59 ` Rust front-end update 2023-04-05 Thomas Schwinge
2023-04-06 9:05 ` Arthur Cohen
2023-04-11 9:09 ` Richard Biener
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=20230405140411.3016563-63-arthur.cohen@embecosm.com \
--to=arthur.cohen@embecosm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc-rust@gcc.gnu.org \
--cc=pierre-emmanuel.patry@embecosm.com \
/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).