]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/rust/typecheck/rust-hir-type-check-implitem.h
Update copyright years.
[thirdparty/gcc.git] / gcc / rust / typecheck / rust-hir-type-check-implitem.h
CommitLineData
a945c346 1// Copyright (C) 2020-2024 Free Software Foundation, Inc.
c6c3db21
PH
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_IMPLITEM_H
20#define RUST_HIR_TYPE_CHECK_IMPLITEM_H
21
22#include "rust-hir-type-check-base.h"
23
24namespace Rust {
25namespace Resolver {
26
27class TypeCheckTopLevelExternItem : public TypeCheckBase,
28 public HIR::HIRExternalItemVisitor
29{
30public:
104cc285
PH
31 static TyTy::BaseType *Resolve (HIR::ExternalItem *item,
32 const HIR::ExternBlock &parent);
c6c3db21
PH
33
34 void visit (HIR::ExternalStaticItem &item) override;
35 void visit (HIR::ExternalFunctionItem &function) override;
36
37private:
38 TypeCheckTopLevelExternItem (const HIR::ExternBlock &parent);
39
40 const HIR::ExternBlock &parent;
104cc285 41 TyTy::BaseType *resolved;
c6c3db21
PH
42};
43
44class TypeCheckImplItem : public TypeCheckBase, public HIR::HIRImplVisitor
45{
46public:
104cc285
PH
47 static TyTy::BaseType *
48 Resolve (HIR::ImplBlock *parent, HIR::ImplItem *item, TyTy::BaseType *self,
49 std::vector<TyTy::SubstitutionParamMapping> substitutions);
c6c3db21
PH
50
51 void visit (HIR::Function &function) override;
52 void visit (HIR::ConstantItem &const_item) override;
53 void visit (HIR::TypeAlias &type_alias) override;
54
55protected:
104cc285
PH
56 TypeCheckImplItem (HIR::ImplBlock *parent, TyTy::BaseType *self,
57 std::vector<TyTy::SubstitutionParamMapping> substitutions);
c6c3db21
PH
58
59 HIR::ImplBlock *parent;
60 TyTy::BaseType *self;
104cc285
PH
61 std::vector<TyTy::SubstitutionParamMapping> substitutions;
62
63 TyTy::BaseType *result;
c6c3db21
PH
64};
65
104cc285
PH
66class TypeCheckImplItemWithTrait : public TypeCheckBase,
67 public HIR::HIRImplVisitor
c6c3db21
PH
68{
69public:
70 static TyTy::TypeBoundPredicateItem
71 Resolve (HIR::ImplBlock *parent, HIR::ImplItem *item, TyTy::BaseType *self,
72 TyTy::TypeBoundPredicate &trait_reference,
73 std::vector<TyTy::SubstitutionParamMapping> substitutions);
74
75 void visit (HIR::ConstantItem &constant) override;
76 void visit (HIR::TypeAlias &type) override;
77 void visit (HIR::Function &function) override;
78
79protected:
80 // this allows us to inherit the must_use specified on a trait definition onto
81 // its implementation
82 void merge_attributes (AST::AttrVec &impl_item_attrs,
83 const HIR::TraitItem &trait_item);
84
85private:
86 TypeCheckImplItemWithTrait (
87 HIR::ImplBlock *parent, TyTy::BaseType *self,
88 TyTy::TypeBoundPredicate &trait_reference,
89 std::vector<TyTy::SubstitutionParamMapping> substitutions);
90
91 bool is_trait_impl_block () const;
92
93 TyTy::TypeBoundPredicate &trait_reference;
94 TyTy::TypeBoundPredicateItem resolved_trait_item;
104cc285
PH
95
96 HIR::ImplBlock *parent;
97 TyTy::BaseType *self;
c6c3db21
PH
98 std::vector<TyTy::SubstitutionParamMapping> substitutions;
99};
100
101} // namespace Resolver
102} // namespace Rust
103
104#endif // RUST_HIR_TYPE_CHECK_IMPLITEM_H