Line data Source code
1 : // Copyright (C) 2021-2026 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 : // Common definitions useful throughout the Rust frontend.
20 :
21 : #ifndef RUST_COMMON
22 : #define RUST_COMMON
23 : #include "rust-system.h"
24 :
25 : namespace Rust {
26 :
27 : enum class Mutability
28 : {
29 : Imm,
30 : Mut
31 : };
32 :
33 : enum class Unsafety
34 : {
35 : Unsafe,
36 : Normal
37 : };
38 :
39 : enum class Const
40 : {
41 : Yes,
42 : No,
43 : };
44 :
45 : enum class Async
46 : {
47 : Yes,
48 : No
49 : };
50 :
51 : enum class Default
52 : {
53 : Yes,
54 : No
55 : };
56 :
57 : enum BoundPolarity
58 : {
59 : RegularBound,
60 : NegativeBound,
61 : AntiBound,
62 : };
63 :
64 : enum AsyncConstStatus
65 : {
66 : NONE,
67 : CONST_FN,
68 : ASYNC_FN
69 : };
70 :
71 : inline std::string
72 0 : enum_to_str (Mutability mut)
73 : {
74 0 : std::string str;
75 0 : switch (mut)
76 : {
77 0 : case Mutability::Imm:
78 0 : return "Imm";
79 0 : case Mutability::Mut:
80 0 : return "Mut";
81 : }
82 0 : gcc_unreachable ();
83 0 : }
84 :
85 : } // namespace Rust
86 :
87 : #endif // RUST_COMMON
|