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