Debian Codegraph @

gcc/rust/typecheck/rust-hir-type-check-base.h

raw
1 // Copyright (C) 2020-2025 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-hir-map.h"
23 #include "rust-hir-type-check.h"
24 #include "rust-name-resolver.h"
25
26 namespace Rust {
27 namespace Resolver {
28
29 class TraitReference;
30 class TypeCheckBase
31 {
32 public:
33 virtual ~TypeCheckBase () {}
34
35 static void ResolveGenericParams (
36 const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
37 std::vector<TyTy::SubstitutionParamMapping> &substitutions, bool is_foreign,
38 ABI abi);
39
40 protected:
41 TypeCheckBase ();
42
43 TraitReference *resolve_trait_path (HIR::TypePath &);
44
45 TyTy::TypeBoundPredicate get_predicate_from_bound (
46 HIR::TypePath &path,
47 tl::optional<std::reference_wrapper<HIR::Type>> associated_self,
48 BoundPolarity polarity = BoundPolarity::RegularBound,
49 bool is_qualified_type = false);
50
51 bool check_for_unconstrained (
52 const std::vector<TyTy::SubstitutionParamMapping> &params_to_constrain,
53 const TyTy::SubstitutionArgumentMappings &constraint_a,
54 const TyTy::SubstitutionArgumentMappings &constraint_b,
55 const TyTy::BaseType *reference);
56
57 TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings,
58 HIR::Literal &literal, location_t locus);
59
60 TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs,
61 location_t locus);
62
63 void resolve_generic_params (
64 const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
65 std::vector<TyTy::SubstitutionParamMapping> &substitutions,
66 bool is_foreign = false, ABI abi = ABI::RUST);
67
68 TyTy::TypeBoundPredicate get_marker_predicate (LangItem::Kind item_type,
69 location_t locus);
70
71 Analysis::Mappings &mappings;
72 Resolver *resolver;
73 TypeCheckContext *context;
74 };
75
76 } // namespace Resolver
77 } // namespace Rust
78
79 #endif // RUST_HIR_TYPE_CHECK_BASE