tree-optimization/112585 - new testcase
[official-gcc.git] / gcc / rust / typecheck / rust-hir-type-check-base.h
blobb8ff2cf6dc9784190417c00825eba49326416c13
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of GCC.
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.
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.
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/>.
19 #ifndef RUST_HIR_TYPE_CHECK_BASE
20 #define RUST_HIR_TYPE_CHECK_BASE
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"
28 namespace Rust {
29 namespace Resolver {
31 class TraitReference;
32 class TypeCheckBase
34 public:
35 virtual ~TypeCheckBase () {}
37 static TyTy::BaseType *unify_site (HirId id, TyTy::TyWithLocation lhs,
38 TyTy::TyWithLocation rhs,
39 Location unify_locus);
41 static TyTy::BaseType *coercion_site (HirId id, TyTy::TyWithLocation lhs,
42 TyTy::TyWithLocation rhs,
43 Location coercion_locus);
45 static TyTy::BaseType *cast_site (HirId id, TyTy::TyWithLocation from,
46 TyTy::TyWithLocation to,
47 Location cast_locus);
49 protected:
50 TypeCheckBase ();
52 TraitReference *resolve_trait_path (HIR::TypePath &);
54 TyTy::TypeBoundPredicate get_predicate_from_bound (HIR::TypePath &path);
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);
62 TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings,
63 HIR::Literal &literal, Location locus);
65 TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs,
66 Location locus);
68 void resolve_generic_params (
69 const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
70 std::vector<TyTy::SubstitutionParamMapping> &substitutions);
72 Analysis::Mappings *mappings;
73 Resolver *resolver;
74 TypeCheckContext *context;
77 } // namespace Resolver
78 } // namespace Rust
80 #endif // RUST_HIR_TYPE_CHECK_BASE