Branch data Line data Source code
1 : : // Copyright (C) 2021-2025 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 BoundPolarity
52 : : {
53 : : RegularBound,
54 : : NegativeBound,
55 : : AntiBound,
56 : : };
57 : :
58 : : enum AsyncConstStatus
59 : : {
60 : : NONE,
61 : : CONST_FN,
62 : : ASYNC_FN
63 : : };
64 : :
65 : : inline std::string
66 : 0 : enum_to_str (Mutability mut)
67 : : {
68 : 0 : std::string str;
69 : 0 : switch (mut)
70 : : {
71 : 0 : case Mutability::Imm:
72 : 0 : return "Imm";
73 : 0 : case Mutability::Mut:
74 : 0 : return "Mut";
75 : : }
76 : 0 : gcc_unreachable ();
77 : 0 : }
78 : :
79 : : } // namespace Rust
80 : :
81 : : #endif // RUST_COMMON
|