| 1 |
// Copyright (C) 2020-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 |
#include "rust-feature.h" |
| 20 |
|
| 21 |
namespace Rust { |
| 22 |
|
| 23 |
Feature |
| 24 |
Feature::create (Feature::Name f) |
| 25 |
{ |
| 26 |
switch (f) |
| 27 |
{ |
| 28 |
case Feature::Name::ASSOCIATED_TYPE_BOUNDS: |
| 29 |
return Feature (Feature::Name::ASSOCIATED_TYPE_BOUNDS, |
| 30 |
Feature::State::ACCEPTED, "associated_type_bounds", |
| 31 |
"1.34.0", 52662); |
| 32 |
case Feature::Name::INTRINSICS: |
| 33 |
return Feature (f, Feature::State::ACCEPTED, "intrinsics", "1.0.0"); |
| 34 |
case Feature::Name::RUSTC_ATTRS: |
| 35 |
return Feature (f, Feature::State::ACCEPTED, "rustc_attrs", "1.0.0"); |
| 36 |
case Feature::Name::DECL_MACRO: |
| 37 |
return Feature (f, Feature::State::ACCEPTED, "decl_macro", "1.0.0", |
| 38 |
39412); |
| 39 |
case Feature::Name::EXTERN_TYPES: |
| 40 |
return Feature (f, Feature::State::ACTIVE, "extern_types", "1.23.0", |
| 41 |
43467); |
| 42 |
case Feature::Name::NEGATIVE_IMPLS: |
| 43 |
return Feature (f, Feature::State::ACTIVE, "negative_impls", "1.0.0", |
| 44 |
68318); |
| 45 |
case Feature::Name::BOX_SYNTAX: |
| 46 |
return Feature (f, Feature::State::ACTIVE, "box_syntax", "1.0.0", 49733); |
| 47 |
case Feature::Name::DROPCK_EYEPATCH: |
| 48 |
return Feature (f, Feature::State::ACTIVE, "dropck_eyepatch", "1.10.0", |
| 49 |
34761); |
| 50 |
case Feature::Name::RAW_REF_OP: |
| 51 |
return Feature (f, Feature::State::ACTIVE, "raw_ref_op", "1.41.0", 64490); |
| 52 |
case Feature::Name::EXCLUSIVE_RANGE_PATTERN: |
| 53 |
return Feature (Feature::Name::EXCLUSIVE_RANGE_PATTERN, |
| 54 |
Feature::State::ACTIVE, "exclusive_range_pattern", |
| 55 |
"1.11.0", 37854); |
| 56 |
case Feature::Name::PRELUDE_IMPORT: |
| 57 |
return Feature (f, Feature::State::ACTIVE, "prelude_import", "1.0.0"); |
| 58 |
case Feature::Name::MIN_SPECIALIZATION: |
| 59 |
return Feature (f, Feature::State::ACTIVE, "min_specialization", |
| 60 |
"1.0.0" /* FIXME: What version here? */, 31844); |
| 61 |
case Feature::Name::AUTO_TRAITS: |
| 62 |
return Feature (f, Feature::State::ACTIVE, "optin_builtin_traits", |
| 63 |
"1.0.0", 13231); |
| 64 |
default: |
| 65 |
rust_unreachable (); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
const std::map<std::string, Feature::Name> Feature::name_hash_map = { |
| 70 |
{"associated_type_bounds", Feature::Name::ASSOCIATED_TYPE_BOUNDS}, |
| 71 |
{"intrinsics", Feature::Name::INTRINSICS}, |
| 72 |
{"rustc_attrs", Feature::Name::RUSTC_ATTRS}, |
| 73 |
{"decl_macro", Feature::Name::DECL_MACRO}, |
| 74 |
{"negative_impls", Feature::Name::NEGATIVE_IMPLS}, |
| 75 |
// TODO: Rename to "auto_traits" when supporting |
| 76 |
// later Rust versions |
| 77 |
{"optin_builtin_traits", Feature::Name::AUTO_TRAITS}, |
| 78 |
{"extern_types", Feature::Name::EXTERN_TYPES}, |
| 79 |
{"lang_items", Feature::Name::LANG_ITEMS}, |
| 80 |
{"no_core", Feature::Name::NO_CORE}, |
| 81 |
{"box_syntax", Feature::Name::BOX_SYNTAX}, |
| 82 |
{"dropck_eyepatch", Feature::Name::DROPCK_EYEPATCH}, |
| 83 |
{"raw_ref_op", Feature::Name::RAW_REF_OP}, |
| 84 |
{"exclusive_range_pattern", Feature::Name::EXCLUSIVE_RANGE_PATTERN}, |
| 85 |
{"prelude_import", Feature::Name::PRELUDE_IMPORT}, |
| 86 |
{"min_specialization", Feature::Name::MIN_SPECIALIZATION}, |
| 87 |
}; // namespace Rust |
| 88 |
|
| 89 |
tl::optional<Feature::Name> |
| 90 |
Feature::as_name (const std::string &name) |
| 91 |
{ |
| 92 |
if (Feature::name_hash_map.count (name)) |
| 93 |
return Feature::name_hash_map.at (name); |
| 94 |
|
| 95 |
return tl::nullopt; |
| 96 |
} |
| 97 |
|
| 98 |
} // namespace Rust |