https://gcc.gnu.org/g:a3172f00f7948b21fdf0861811d07713709856c8
commit r17-4358-ga3172f00f7948b21fdf0861811d07713709856c8 Author: Arthur Cohen <[email protected]> Date: Fri Sep 4 14:14:19 2026 +0200 gccrs: feature-gate: Return a value to indicate the result of gating 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. Diff: --- 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 775df43791ae..3d43d736ecee 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 e8bb61b1f610..74d81a5e1ae0 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
