]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/rust/hir/rust-ast-lower-type.h
Daily bump.
[thirdparty/gcc.git] / gcc / rust / hir / rust-ast-lower-type.h
CommitLineData
6441eb6d 1// Copyright (C) 2020-2025 Free Software Foundation, Inc.
7999cf32
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_AST_LOWER_TYPE
20#define RUST_AST_LOWER_TYPE
21
22#include "rust-ast-lower-base.h"
7999cf32 23#include "rust-ast-lower-expr.h"
c7c6b5f8 24#include "rust-hir-path.h"
cd8547f8 25#include "rust-type.h"
7999cf32
PH
26
27namespace Rust {
28namespace HIR {
29
30class ASTLowerTypePath : public ASTLoweringBase
31{
32protected:
33 using Rust::HIR::ASTLoweringBase::visit;
34
35public:
63023c03 36 static HIR::TypePath *translate (AST::TypePath &type);
7999cf32 37
875f722d
PH
38 void visit (AST::TypePathSegmentFunction &segment) override;
39 void visit (AST::TypePathSegment &segment) override;
7999cf32 40 void visit (AST::TypePathSegmentGeneric &segment) override;
875f722d 41 void visit (AST::TypePath &path) override;
7999cf32
PH
42
43protected:
44 HIR::TypePathSegment *translated_segment;
45
46private:
47 HIR::TypePath *translated;
48};
49
50class ASTLowerQualifiedPathInType : public ASTLowerTypePath
51{
52 using ASTLowerTypePath::visit;
53
54public:
875f722d 55 static HIR::QualifiedPathInType *translate (AST::QualifiedPathInType &type);
7999cf32
PH
56
57 void visit (AST::QualifiedPathInType &path) override;
58
59private:
60 HIR::QualifiedPathInType *translated;
61};
62
63class ASTLoweringType : public ASTLoweringBase
64{
65 using Rust::HIR::ASTLoweringBase::visit;
66
67public:
e01c9f40 68 static HIR::Type *translate (AST::Type &type,
bc1a47f7 69 bool default_to_static_lifetime = false);
7999cf32 70
8220e7b7
AC
71 void visit (AST::BareFunctionType &fntype) override;
72 void visit (AST::TupleType &tuple) override;
73 void visit (AST::TypePath &path) override;
74 void visit (AST::QualifiedPathInType &path) override;
75 void visit (AST::ArrayType &type) override;
76 void visit (AST::ReferenceType &type) override;
77 void visit (AST::RawPointerType &type) override;
78 void visit (AST::SliceType &type) override;
79 void visit (AST::InferredType &type) override;
80 void visit (AST::NeverType &type) override;
7999cf32 81 void visit (AST::TraitObjectTypeOneBound &type) override;
7999cf32 82 void visit (AST::TraitObjectType &type) override;
cd8547f8 83 void visit (AST::ParenthesisedType &type) override;
7999cf32 84
271a3489
PH
85 void visit (AST::ImplTraitType &type) override;
86 void visit (AST::ImplTraitTypeOneBound &type) override;
87
7999cf32 88private:
bc1a47f7
JD
89 ASTLoweringType (bool default_to_static_lifetime)
90 : ASTLoweringBase (),
91 default_to_static_lifetime (default_to_static_lifetime),
92 translated (nullptr)
93 {}
94
95 /** Used when compiling const and static items. */
96 bool default_to_static_lifetime;
7999cf32
PH
97
98 HIR::Type *translated;
99};
100
101class ASTLowerGenericParam : public ASTLoweringBase
102{
103 using Rust::HIR::ASTLoweringBase::visit;
104
105public:
e01c9f40 106 static HIR::GenericParam *translate (AST::GenericParam &param);
8220e7b7
AC
107
108 void visit (AST::LifetimeParam &param) override;
109 void visit (AST::ConstGenericParam &param) override;
110 void visit (AST::TypeParam &param) override;
7999cf32
PH
111
112private:
113 ASTLowerGenericParam () : ASTLoweringBase (), translated (nullptr) {}
114
115 HIR::GenericParam *translated;
116};
117
118class ASTLoweringTypeBounds : public ASTLoweringBase
119{
120 using Rust::HIR::ASTLoweringBase::visit;
121
122public:
e01c9f40 123 static HIR::TypeParamBound *translate (AST::TypeParamBound &type);
8220e7b7
AC
124
125 void visit (AST::TraitBound &bound) override;
126 void visit (AST::Lifetime &bound) override;
7999cf32
PH
127
128private:
129 ASTLoweringTypeBounds () : ASTLoweringBase (), translated (nullptr) {}
130
131 HIR::TypeParamBound *translated;
132};
133
134class ASTLowerWhereClauseItem : public ASTLoweringBase
135{
136 using Rust::HIR::ASTLoweringBase::visit;
137
138public:
8220e7b7
AC
139 static HIR::WhereClauseItem *translate (AST::WhereClauseItem &item);
140
141 void visit (AST::LifetimeWhereClauseItem &item) override;
142 void visit (AST::TypeBoundWhereClauseItem &item) override;
7999cf32
PH
143
144private:
145 ASTLowerWhereClauseItem () : ASTLoweringBase (), translated (nullptr) {}
146
147 HIR::WhereClauseItem *translated;
148};
149
150} // namespace HIR
151} // namespace Rust
152
153#endif // RUST_AST_LOWER_TYPE