(root)/
gcc-13.2.0/
gcc/
rust/
typecheck/
rust-hir-type-check-base.h
       1  // Copyright (C) 2020-2023 Free Software Foundation, Inc.
       2  
       3  // This file is part of GCC.
       4  
       5  // GCC is free software; you can redistribute it and/or modify it under
       6  // the terms of the GNU General Public License as published by the Free
       7  // Software Foundation; either version 3, or (at your option) any later
       8  // version.
       9  
      10  // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11  // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13  // for more details.
      14  
      15  // You should have received a copy of the GNU General Public License
      16  // along with GCC; see the file COPYING3.  If not see
      17  // <http://www.gnu.org/licenses/>.
      18  
      19  #ifndef RUST_HIR_TYPE_CHECK_BASE
      20  #define RUST_HIR_TYPE_CHECK_BASE
      21  
      22  #include "rust-diagnostics.h"
      23  #include "rust-hir-type-check.h"
      24  #include "rust-name-resolver.h"
      25  #include "rust-hir-visitor.h"
      26  #include "rust-hir-map.h"
      27  
      28  namespace Rust {
      29  namespace Resolver {
      30  
      31  class TraitReference;
      32  class TypeCheckBase
      33  {
      34  public:
      35    virtual ~TypeCheckBase () {}
      36  
      37    static TyTy::BaseType *unify_site (HirId id, TyTy::TyWithLocation lhs,
      38  				     TyTy::TyWithLocation rhs,
      39  				     Location unify_locus);
      40  
      41    static TyTy::BaseType *coercion_site (HirId id, TyTy::TyWithLocation lhs,
      42  					TyTy::TyWithLocation rhs,
      43  					Location coercion_locus);
      44  
      45    static TyTy::BaseType *cast_site (HirId id, TyTy::TyWithLocation from,
      46  				    TyTy::TyWithLocation to,
      47  				    Location cast_locus);
      48  
      49  protected:
      50    TypeCheckBase ();
      51  
      52    TraitReference *resolve_trait_path (HIR::TypePath &);
      53  
      54    TyTy::TypeBoundPredicate get_predicate_from_bound (HIR::TypePath &path);
      55  
      56    bool check_for_unconstrained (
      57      const std::vector<TyTy::SubstitutionParamMapping> &params_to_constrain,
      58      const TyTy::SubstitutionArgumentMappings &constraint_a,
      59      const TyTy::SubstitutionArgumentMappings &constraint_b,
      60      const TyTy::BaseType *reference);
      61  
      62    TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings,
      63  				   HIR::Literal &literal, Location locus);
      64  
      65    TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs,
      66  						 Location locus);
      67  
      68    void resolve_generic_params (
      69      const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
      70      std::vector<TyTy::SubstitutionParamMapping> &substitutions);
      71  
      72    Analysis::Mappings *mappings;
      73    Resolver *resolver;
      74    TypeCheckContext *context;
      75  };
      76  
      77  } // namespace Resolver
      78  } // namespace Rust
      79  
      80  #endif // RUST_HIR_TYPE_CHECK_BASE