Line data Source code
1 : // Copyright (C) 2020-2026 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 829537 : virtual ~TypeCheckBase () {}
34 :
35 : static void ResolveGenericParams (
36 : const HIR::Item::ItemKind item_kind, location_t item_locus,
37 : const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
38 : std::vector<TyTy::SubstitutionParamMapping> &substitutions, bool is_foreign,
39 : ABI abi);
40 :
41 : static TyTy::TypeBoundPredicate ResolvePredicateFromBound (
42 : HIR::TypePath &path,
43 : tl::optional<std::reference_wrapper<HIR::Type>> associated_self,
44 : BoundPolarity polarity = BoundPolarity::RegularBound,
45 : bool is_qualified_type = false, bool is_super_trait = false);
46 :
47 : protected:
48 : TypeCheckBase ();
49 :
50 : TraitReference *resolve_trait_path (HIR::TypePath &);
51 :
52 : TyTy::TypeBoundPredicate get_predicate_from_bound (
53 : HIR::TypePath &path,
54 : tl::optional<std::reference_wrapper<HIR::Type>> associated_self,
55 : BoundPolarity polarity = BoundPolarity::RegularBound,
56 : bool is_qualified_type = false, bool is_super_trait = false,
57 : bool defer_bindings = false);
58 :
59 : bool check_for_unconstrained (
60 : const std::vector<TyTy::SubstitutionParamMapping> ¶ms_to_constrain,
61 : const TyTy::SubstitutionArgumentMappings &constraint_a,
62 : const TyTy::SubstitutionArgumentMappings &constraint_b,
63 : TyTy::BaseType *reference);
64 :
65 : TyTy::BaseType *resolve_literal (const Analysis::NodeMapping &mappings,
66 : HIR::Literal &literal, location_t locus);
67 :
68 : TyTy::ADTType::ReprOptions parse_repr_options (const AST::AttrVec &attrs,
69 : location_t locus);
70 :
71 : void resolve_generic_params (
72 : const HIR::Item::ItemKind item_kind, location_t item_locus,
73 : const std::vector<std::unique_ptr<HIR::GenericParam>> &generic_params,
74 : std::vector<TyTy::SubstitutionParamMapping> &substitutions,
75 : bool is_foreign = false, ABI abi = ABI::RUST);
76 :
77 : TyTy::TypeBoundPredicate get_marker_predicate (LangItem::Kind item_type,
78 : location_t locus);
79 :
80 : Analysis::Mappings &mappings;
81 : TypeCheckContext *context;
82 : };
83 :
84 : } // namespace Resolver
85 : } // namespace Rust
86 :
87 : #endif // RUST_HIR_TYPE_CHECK_BASE
|