gccrs: Add support for feature check.
[official-gcc.git] / gcc / rust / checks / errors / rust-feature.h
blobbf93b090af5951e05afa2ce1a56aa7fc506775e5
1 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
3 // This file is part of GCC.
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.
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.
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/>.
19 #ifndef RUST_FEATURE_H
20 #define RUST_FEATURE_H
22 #include "rust-session-manager.h"
23 #include "rust-optional.h"
25 namespace Rust {
27 class Feature
29 public:
30 enum class State
32 ACCEPTED,
33 ACTIVE,
34 REMOVED,
35 STABILIZED,
38 enum class Name
40 ASSOCIATED_TYPE_BOUNDS,
41 INTRINSICS,
42 RUSTC_ATTRS,
43 DECL_MACRO,
46 const std::string &as_string () { return m_name_str; }
47 Name name () { return m_name; }
48 const std::string &description () { return m_description; }
49 State state () { return m_state; }
51 static Optional<Name> as_name (const std::string &name);
52 static Feature create (Name name);
54 private:
55 Feature (Name name, State state, const char *name_str,
56 const char *rustc_since, uint64_t issue_number,
57 const Optional<CompileOptions::Edition> &edition,
58 const char *description)
59 : m_state (state), m_name (name), m_name_str (name_str),
60 m_rustc_since (rustc_since), issue (issue_number), edition (edition),
61 m_description (description)
64 State m_state;
65 Name m_name;
66 std::string m_name_str;
67 std::string m_rustc_since;
68 uint64_t issue;
69 Optional<CompileOptions::Edition> edition;
70 std::string m_description;
72 static const std::map<std::string, Name> name_hash_map;
75 } // namespace Rust
76 #endif