]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/typecheck/rust-hir-type-check-base.h
Update copyright years.
[thirdparty/gcc.git] / 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 #include "rust-backend.h"
28
29 namespace Rust {
30 namespace Resolver {
31
32 class TraitReference;
33 class TypeCheckBase
34 {
35 public:
36 virtual ~TypeCheckBase () {}
37
38 static TyTy::BaseType *coercion_site (HirId id, TyTy::BaseType *lhs,
39 TyTy::BaseType *rhs,
40 Location coercion_locus);
41
42 static TyTy::BaseType *cast_site (HirId id, TyTy::TyWithLocation from,
43 TyTy::TyWithLocation to,
44 Location cast_locus);
45
46 protected:
47 TypeCheckBase ()
48 : mappings (Analysis::Mappings::get ()), resolver (Resolver::get ()),
49 context (TypeCheckContext::get ())
50 {}
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