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