Debian Codegraph @

gcc/rust/typecheck/rust-hir-trait-resolve.h

raw
1 // Copyright (C) 2021-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_TRAIT_RESOLVE_H
20 #define RUST_HIR_TRAIT_RESOLVE_H
21
22 #include "rust-hir-type-check-type.h"
23 #include "rust-hir-visitor.h"
24
25 namespace Rust {
26 namespace Resolver {
27
28 class ResolveTraitItemToRef : public TypeCheckBase,
29 private HIR::HIRTraitItemVisitor
30 {
31 public:
32 static TraitItemReference
33 Resolve (HIR::TraitItem &item, TyTy::BaseType *self,
34 std::vector<TyTy::SubstitutionParamMapping> substitutions);
35
36 void visit (HIR::TraitItemType &type) override;
37
38 void visit (HIR::TraitItemConst &cst) override;
39
40 void visit (HIR::TraitItemFunc &fn) override;
41
42 private:
43 ResolveTraitItemToRef (
44 TyTy::BaseType *self,
45 std::vector<TyTy::SubstitutionParamMapping> &&substitutions);
46
47 TraitItemReference resolved;
48 TyTy::BaseType *self;
49 std::vector<TyTy::SubstitutionParamMapping> substitutions;
50 };
51
52 class TraitResolver : public TypeCheckBase
53 {
54 public:
55 static TraitReference *Resolve (HIR::TypePath &path);
56
57 static TraitReference *Resolve (HIR::Trait &trait);
58
59 static TraitReference *Lookup (HIR::TypePath &path);
60
61 static HIR::Trait *ResolveHirItem (const HIR::TypePath &path);
62
63 private:
64 TraitResolver ();
65
66 TraitReference *resolve_path (HIR::TypePath &path);
67
68 TraitReference *resolve_trait (HIR::Trait *trait_reference);
69
70 TraitReference *lookup_path (HIR::TypePath &path);
71
72 bool resolve_path_to_trait (const HIR::TypePath &path,
73 HIR::Trait **resolved) const;
74 };
75
76 } // namespace Resolver
77 } // namespace Rust
78
79 #endif // RUST_HIR_TRAIT_RESOLVE_H