From: Arthur Cohen <[email protected]>

Create a new enum class to indicate whether a feature was gated or not
to the FeatureGate checker.

As well as moving `gate` into a public function since the aim is to make
it available to other passes.

gcc/rust/ChangeLog:

        * checks/errors/feature/rust-feature-gate.cc (FeatureGate::gate): Move 
into public
        methods, use GateResult enum.
        * checks/errors/feature/rust-feature-gate.h: Add new GateResult enum.
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/39400fa35ea699d035781029b0f402daa2b94b95

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4846

 gcc/rust/checks/errors/feature/rust-feature-gate.cc |  6 +++++-
 gcc/rust/checks/errors/feature/rust-feature-gate.h  | 10 +++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/checks/errors/feature/rust-feature-gate.cc 
b/gcc/rust/checks/errors/feature/rust-feature-gate.cc
index 775df4379..3d43d736e 100644
--- a/gcc/rust/checks/errors/feature/rust-feature-gate.cc
+++ b/gcc/rust/checks/errors/feature/rust-feature-gate.cc
@@ -76,7 +76,7 @@ FeatureGate::visit (AST::Crate &crate)
     }
 }
 
-void
+FeatureGate::GateResult
 FeatureGate::gate (Feature::Name name, location_t loc,
                   const std::string &error_msg)
 {
@@ -102,7 +102,11 @@ FeatureGate::gate (Feature::Name name, location_t loc,
          rust_error_at (loc, ErrorCode::E0658, fmt_str, error_msg.c_str (),
                         feature.as_string ().c_str ());
        }
+
+      return GateResult::Gated;
     }
+
+  return GateResult::Allowed;
 }
 
 void
diff --git a/gcc/rust/checks/errors/feature/rust-feature-gate.h 
b/gcc/rust/checks/errors/feature/rust-feature-gate.h
index e8bb61b1f..74d81a5e1 100644
--- a/gcc/rust/checks/errors/feature/rust-feature-gate.h
+++ b/gcc/rust/checks/errors/feature/rust-feature-gate.h
@@ -52,8 +52,16 @@ public:
   void visit (AST::Enum &enum_item) override;
   void visit (AST::EnumItem &enum_variant) override;
 
+  enum class GateResult
+  {
+    Gated,
+    Allowed,
+  };
+
+  GateResult gate (Feature::Name name, location_t loc,
+                  const std::string &error_msg);
+
 private:
-  void gate (Feature::Name name, location_t loc, const std::string &error_msg);
   void check_no_core_attribute (const AST::Attribute &attribute);
   void check_rustc_attri (const std::vector<AST::Attribute> &attributes);
   void

base-commit: 72ccc38c4a3abf87b61500c5d8fae571e0a37164
-- 
2.55.0

Reply via email to