[PR testsuite/116860] Testsuite adjustment for recently added tests
[official-gcc.git] / gcc / rust / typecheck / rust-hir-type-check-implitem.h
blob4fb2256c6b4338d7967abd1eb1cb29ced7ea7b5a
1 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
3 // This file is part of GCC.
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.
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.
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/>.
19 #ifndef RUST_HIR_TYPE_CHECK_IMPLITEM_H
20 #define RUST_HIR_TYPE_CHECK_IMPLITEM_H
22 #include "rust-hir-type-check-base.h"
23 #include "rust-hir-visitor.h"
25 namespace Rust {
26 namespace Resolver {
28 class TypeCheckTopLevelExternItem : public TypeCheckBase,
29 public HIR::HIRExternalItemVisitor
31 public:
32 static TyTy::BaseType *Resolve (HIR::ExternalItem *item,
33 const HIR::ExternBlock &parent);
35 void visit (HIR::ExternalStaticItem &item) override;
36 void visit (HIR::ExternalFunctionItem &function) override;
37 void visit (HIR::ExternalTypeItem &type) override;
39 private:
40 TypeCheckTopLevelExternItem (const HIR::ExternBlock &parent);
42 const HIR::ExternBlock &parent;
43 TyTy::BaseType *resolved;
46 class TypeCheckImplItem : public TypeCheckBase, public HIR::HIRImplVisitor
48 public:
49 static TyTy::BaseType *
50 Resolve (HIR::ImplBlock *parent, HIR::ImplItem *item, TyTy::BaseType *self,
51 std::vector<TyTy::SubstitutionParamMapping> substitutions);
53 void visit (HIR::Function &function) override;
54 void visit (HIR::ConstantItem &const_item) override;
55 void visit (HIR::TypeAlias &type_alias) override;
57 protected:
58 TypeCheckImplItem (HIR::ImplBlock *parent, TyTy::BaseType *self,
59 std::vector<TyTy::SubstitutionParamMapping> substitutions);
61 HIR::ImplBlock *parent;
62 TyTy::BaseType *self;
63 std::vector<TyTy::SubstitutionParamMapping> substitutions;
65 TyTy::BaseType *result = nullptr;
68 class TypeCheckImplItemWithTrait : public TypeCheckBase,
69 public HIR::HIRImplVisitor
71 public:
72 static TyTy::TypeBoundPredicateItem
73 Resolve (HIR::ImplBlock *parent, HIR::ImplItem *item, TyTy::BaseType *self,
74 TyTy::TypeBoundPredicate &trait_reference,
75 std::vector<TyTy::SubstitutionParamMapping> substitutions);
77 void visit (HIR::ConstantItem &constant) override;
78 void visit (HIR::TypeAlias &type) override;
79 void visit (HIR::Function &function) override;
81 protected:
82 // this allows us to inherit the must_use specified on a trait definition onto
83 // its implementation
84 void merge_attributes (AST::AttrVec &impl_item_attrs,
85 const HIR::TraitItem &trait_item);
87 private:
88 TypeCheckImplItemWithTrait (
89 HIR::ImplBlock *parent, TyTy::BaseType *self,
90 TyTy::TypeBoundPredicate &trait_reference,
91 std::vector<TyTy::SubstitutionParamMapping> substitutions);
93 bool is_trait_impl_block () const;
95 TyTy::TypeBoundPredicate &trait_reference;
96 TyTy::TypeBoundPredicateItem resolved_trait_item;
98 HIR::ImplBlock *parent;
99 TyTy::BaseType *self;
100 std::vector<TyTy::SubstitutionParamMapping> substitutions;
101 TyTy::RegionConstraints region_constraints;
104 } // namespace Resolver
105 } // namespace Rust
107 #endif // RUST_HIR_TYPE_CHECK_IMPLITEM_H