From: Arthur Cohen <[email protected]>

Remove container of incomplete type and reorder headers.

gcc/rust/ChangeLog:

        * typecheck/rust-tyty-subst.h: Remove now useless inclusion.
        * typecheck/rust-tyty.h (class TypeBoundPredicate): New, moved from 
rust-tyty-bounds.h
        (class TypeBoundsMappings): Likewise.
        * typecheck/rust-tyty-bounds.h: Removed.
---
 gcc/rust/typecheck/rust-tyty-bounds.h |  66 --------
 gcc/rust/typecheck/rust-tyty-subst.h  |   1 -
 gcc/rust/typecheck/rust-tyty.h        | 216 +++++++++++++++-----------
 3 files changed, 121 insertions(+), 162 deletions(-)
 delete mode 100644 gcc/rust/typecheck/rust-tyty-bounds.h

diff --git a/gcc/rust/typecheck/rust-tyty-bounds.h 
b/gcc/rust/typecheck/rust-tyty-bounds.h
deleted file mode 100644
index 6392af1fed4..00000000000
--- a/gcc/rust/typecheck/rust-tyty-bounds.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2020-2025 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/>.
-
-#ifndef RUST_TYTY_BOUNDS_H
-#define RUST_TYTY_BOUNDS_H
-
-#include "rust-location.h"
-#include "rust-mapping-common.h"
-
-namespace Rust {
-
-namespace Resolver {
-class TraitReference;
-class TraitItemReference;
-class AssociatedImplTrait;
-} // namespace Resolver
-
-namespace TyTy {
-
-class BaseType;
-class TypeBoundPredicate;
-class TypeBoundsMappings
-{
-protected:
-  TypeBoundsMappings (std::vector<TypeBoundPredicate> specified_bounds);
-
-public:
-  std::vector<TypeBoundPredicate> &get_specified_bounds ();
-
-  const std::vector<TypeBoundPredicate> &get_specified_bounds () const;
-
-  TypeBoundPredicate lookup_predicate (DefId id);
-
-  size_t num_specified_bounds () const;
-
-  std::string raw_bounds_as_string () const;
-
-  std::string bounds_as_string () const;
-
-  std::string raw_bounds_as_name () const;
-
-protected:
-  void add_bound (TypeBoundPredicate predicate);
-
-  std::vector<TypeBoundPredicate> specified_bounds;
-};
-
-} // namespace TyTy
-} // namespace Rust
-
-#endif // RUST_TYTY_BOUNDS_H
diff --git a/gcc/rust/typecheck/rust-tyty-subst.h 
b/gcc/rust/typecheck/rust-tyty-subst.h
index c1bc96a7f8a..d09e180147a 100644
--- a/gcc/rust/typecheck/rust-tyty-subst.h
+++ b/gcc/rust/typecheck/rust-tyty-subst.h
@@ -22,7 +22,6 @@
 #include "rust-system.h"
 #include "rust-location.h"
 #include "rust-hir-full-decls.h"
-#include "rust-tyty-bounds.h"
 #include "rust-tyty-region.h"
 #include "rust-ast.h"
 #include "optional.h"
diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h
index ed3cd76807c..50f6347e33f 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -24,7 +24,6 @@
 #include "rust-common.h"
 #include "rust-identifier.h"
 #include "rust-abi.h"
-#include "rust-tyty-bounds.h"
 #include "rust-tyty-util.h"
 #include "rust-tyty-subst.h"
 #include "rust-tyty-region.h"
@@ -92,6 +91,127 @@ public:
 class TyVisitor;
 class TyConstVisitor;
 class BaseConstType;
+
+class TypeBoundPredicate : public SubstitutionRef
+{
+public:
+  TypeBoundPredicate (const Resolver::TraitReference &trait_reference,
+                     BoundPolarity polarity, location_t locus);
+
+  TypeBoundPredicate (DefId reference,
+                     std::vector<SubstitutionParamMapping> substitutions,
+                     BoundPolarity polarity, location_t locus);
+
+  TypeBoundPredicate (const TypeBoundPredicate &other);
+
+  virtual ~TypeBoundPredicate () {}
+
+  TypeBoundPredicate &operator= (const TypeBoundPredicate &other);
+
+  static TypeBoundPredicate error ();
+
+  std::string as_string () const;
+
+  std::string as_name () const;
+
+  const Resolver::TraitReference *get () const;
+
+  location_t get_locus () const { return locus; }
+
+  std::string get_name () const;
+
+  // check that this  is object-safe see:
+  // https://doc.rust-lang.org/reference/items/traits.html#object-safety
+  bool is_object_safe (bool emit_error, location_t locus) const;
+
+  void apply_generic_arguments (HIR::GenericArgs *generic_args,
+                               bool has_associated_self, bool is_super_trait);
+
+  void apply_argument_mappings (SubstitutionArgumentMappings &arguments,
+                               bool is_super_trait);
+
+  bool contains_item (const std::string &search) const;
+
+  tl::optional<TypeBoundPredicateItem>
+  lookup_associated_item (const std::string &search) const;
+
+  tl::optional<TypeBoundPredicateItem>
+  lookup_associated_item (const Resolver::TraitItemReference *ref) const;
+
+  // WARNING THIS WILL ALWAYS RETURN NULLPTR
+  BaseType *
+  handle_substitions (SubstitutionArgumentMappings &mappings) override final;
+
+  bool is_error () const;
+
+  bool requires_generic_args () const;
+
+  bool contains_associated_types () const;
+
+  DefId get_id () const { return reference; }
+
+  BoundPolarity get_polarity () const { return polarity; }
+
+  std::vector<TypeBoundPredicateItem> get_associated_type_items ();
+
+  size_t get_num_associated_bindings () const override final;
+
+  TypeBoundPredicateItem
+  lookup_associated_type (const std::string &search) override final;
+
+  bool is_equal (const TypeBoundPredicate &other) const;
+
+  bool validate_type_implements_super_traits (TyTy::BaseType &self,
+                                             HIR::Type &impl_type,
+                                             HIR::Type &trait) const;
+
+  bool validate_type_implements_this (TyTy::BaseType &self,
+                                     HIR::Type &impl_type,
+                                     HIR::Type &trait) const;
+
+private:
+  struct mark_is_error
+  {
+  };
+
+  TypeBoundPredicate (mark_is_error);
+
+  void get_trait_hierachy (
+    std::function<void (const Resolver::TraitReference &)> callback) const;
+
+  DefId reference;
+  location_t locus;
+  bool error_flag;
+  BoundPolarity polarity;
+  std::vector<TyTy::TypeBoundPredicate> super_traits;
+};
+
+class TypeBoundsMappings
+{
+protected:
+  TypeBoundsMappings (std::vector<TypeBoundPredicate> specified_bounds);
+
+public:
+  std::vector<TypeBoundPredicate> &get_specified_bounds ();
+
+  const std::vector<TypeBoundPredicate> &get_specified_bounds () const;
+
+  TypeBoundPredicate lookup_predicate (DefId id);
+
+  size_t num_specified_bounds () const;
+
+  std::string raw_bounds_as_string () const;
+
+  std::string bounds_as_string () const;
+
+  std::string raw_bounds_as_name () const;
+
+protected:
+  void add_bound (TypeBoundPredicate predicate);
+
+  std::vector<TypeBoundPredicate> specified_bounds;
+};
+
 class BaseType : public TypeBoundsMappings
 {
 public:
@@ -671,100 +791,6 @@ private:
   std::vector<TyVar> fields;
 };
 
-class TypeBoundPredicate : public SubstitutionRef
-{
-public:
-  TypeBoundPredicate (const Resolver::TraitReference &trait_reference,
-                     BoundPolarity polarity, location_t locus);
-
-  TypeBoundPredicate (DefId reference,
-                     std::vector<SubstitutionParamMapping> substitutions,
-                     BoundPolarity polarity, location_t locus);
-
-  TypeBoundPredicate (const TypeBoundPredicate &other);
-
-  virtual ~TypeBoundPredicate () {}
-
-  TypeBoundPredicate &operator= (const TypeBoundPredicate &other);
-
-  static TypeBoundPredicate error ();
-
-  std::string as_string () const;
-
-  std::string as_name () const;
-
-  const Resolver::TraitReference *get () const;
-
-  location_t get_locus () const { return locus; }
-
-  std::string get_name () const;
-
-  // check that this  is object-safe see:
-  // https://doc.rust-lang.org/reference/items/traits.html#object-safety
-  bool is_object_safe (bool emit_error, location_t locus) const;
-
-  void apply_generic_arguments (HIR::GenericArgs *generic_args,
-                               bool has_associated_self, bool is_super_trait);
-
-  void apply_argument_mappings (SubstitutionArgumentMappings &arguments,
-                               bool is_super_trait);
-
-  bool contains_item (const std::string &search) const;
-
-  tl::optional<TypeBoundPredicateItem>
-  lookup_associated_item (const std::string &search) const;
-
-  tl::optional<TypeBoundPredicateItem>
-  lookup_associated_item (const Resolver::TraitItemReference *ref) const;
-
-  // WARNING THIS WILL ALWAYS RETURN NULLPTR
-  BaseType *
-  handle_substitions (SubstitutionArgumentMappings &mappings) override final;
-
-  bool is_error () const;
-
-  bool requires_generic_args () const;
-
-  bool contains_associated_types () const;
-
-  DefId get_id () const { return reference; }
-
-  BoundPolarity get_polarity () const { return polarity; }
-
-  std::vector<TypeBoundPredicateItem> get_associated_type_items ();
-
-  size_t get_num_associated_bindings () const override final;
-
-  TypeBoundPredicateItem
-  lookup_associated_type (const std::string &search) override final;
-
-  bool is_equal (const TypeBoundPredicate &other) const;
-
-  bool validate_type_implements_super_traits (TyTy::BaseType &self,
-                                             HIR::Type &impl_type,
-                                             HIR::Type &trait) const;
-
-  bool validate_type_implements_this (TyTy::BaseType &self,
-                                     HIR::Type &impl_type,
-                                     HIR::Type &trait) const;
-
-private:
-  struct mark_is_error
-  {
-  };
-
-  TypeBoundPredicate (mark_is_error);
-
-  void get_trait_hierachy (
-    std::function<void (const Resolver::TraitReference &)> callback) const;
-
-  DefId reference;
-  location_t locus;
-  bool error_flag;
-  BoundPolarity polarity;
-  std::vector<TyTy::TypeBoundPredicate> super_traits;
-};
-
 class TypeBoundPredicateItem
 {
 public:
-- 
2.50.1

Reply via email to