(root)/
gcc-13.2.0/
gcc/
rust/
checks/
errors/
rust-feature.h
       1  // Copyright (C) 2020-2023 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  #ifndef RUST_FEATURE_H
      20  #define RUST_FEATURE_H
      21  
      22  #include "rust-session-manager.h"
      23  #include "rust-optional.h"
      24  
      25  namespace Rust {
      26  
      27  class Feature
      28  {
      29  public:
      30    enum class State
      31    {
      32      ACCEPTED,
      33      ACTIVE,
      34      REMOVED,
      35      STABILIZED,
      36    };
      37  
      38    enum class Name
      39    {
      40      ASSOCIATED_TYPE_BOUNDS,
      41      INTRINSICS,
      42      RUSTC_ATTRS,
      43      DECL_MACRO,
      44    };
      45  
      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; }
      50    uint64_t issue () { return m_issue; }
      51  
      52    static Optional<Name> as_name (const std::string &name);
      53    static Feature create (Name name);
      54  
      55  private:
      56    Feature (Name name, State state, const char *name_str,
      57  	   const char *rustc_since, uint64_t issue_number,
      58  	   const Optional<CompileOptions::Edition> &edition,
      59  	   const char *description)
      60      : m_state (state), m_name (name), m_name_str (name_str),
      61        m_rustc_since (rustc_since), m_issue (issue_number), edition (edition),
      62        m_description (description)
      63    {}
      64  
      65    State m_state;
      66    Name m_name;
      67    std::string m_name_str;
      68    std::string m_rustc_since;
      69    uint64_t m_issue;
      70    Optional<CompileOptions::Edition> edition;
      71    std::string m_description;
      72  
      73    static const std::map<std::string, Name> name_hash_map;
      74  };
      75  
      76  } // namespace Rust
      77  #endif