]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add raw_ref_op feature gate
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 21 May 2024 08:58:55 +0000 (10:58 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 17 Mar 2025 15:35:33 +0000 (16:35 +0100)
Raw ref operators are still experimental and shall not slip within
stable rust, they should therefore be feature gated.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Gate raw
borrow.
* checks/errors/rust-feature-gate.h: Update function prototype.
* checks/errors/rust-feature.cc: Add raw_ref_op gate.
* checks/errors/rust-feature.h: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/checks/errors/rust-feature-gate.cc
gcc/rust/checks/errors/rust-feature-gate.h
gcc/rust/checks/errors/rust-feature.cc
gcc/rust/checks/errors/rust-feature.h

index 16c5ecee6cbd925f638fd5f8c88d85edad63ffbd..8f9e991237b641566d96f2082aae8d1116303771 100644 (file)
@@ -201,4 +201,12 @@ FeatureGate::visit (AST::TypeParam &param)
   AST::DefaultASTVisitor::visit (param);
 }
 
+void
+FeatureGate::visit (AST::BorrowExpr &expr)
+{
+  if (expr.is_raw_borrow ())
+    gate (Feature::Name::RAW_REF_OP, expr.get_locus (),
+         "raw address of syntax is experimental");
+}
+
 } // namespace Rust
index 5ead11030865164b5e307390b340d1bbc3f45c6a..a31405e7d63de2e0c0fd3aeda0e2201a68edea7c 100644 (file)
@@ -54,7 +54,7 @@ public:
   void visit (AST::AttrInputMacro &attr_input) override {}
   void visit (AST::MetaItemLitExpr &meta_item) override {}
   void visit (AST::MetaItemPathLit &meta_item) override {}
-  void visit (AST::BorrowExpr &expr) override {}
+  void visit (AST::BorrowExpr &expr) override;
   void visit (AST::DereferenceExpr &expr) override {}
   void visit (AST::ErrorPropagationExpr &expr) override {}
   void visit (AST::NegationExpr &expr) override {}
index b9a648e62ef8c2a2da8cccb6a99e96b2d539f390..bc8aa915064d4da3e7ec67aa454c34dbf07f8d50 100644 (file)
@@ -51,6 +51,9 @@ Feature::create (Feature::Name name)
     case Feature::Name::DROPCK_EYEPATCH:
       return Feature (Feature::Name::DROPCK_EYEPATCH, Feature::State::ACTIVE,
                      "dropck_eyepatch", "1.10.0", 34761, tl::nullopt, "");
+    case Feature::Name::RAW_REF_OP:
+      return Feature (Feature::Name::RAW_REF_OP, Feature::State::ACTIVE,
+                     "raw_ref_op", "1.41.0", 64490, tl::nullopt, "");
     default:
       rust_unreachable ();
     }
@@ -70,6 +73,7 @@ const std::map<std::string, Feature::Name> Feature::name_hash_map = {
   {"no_core", Feature::Name::NO_CORE},
   {"box_syntax", Feature::Name::BOX_SYNTAX},
   {"dropck_eyepatch", Feature::Name::DROPCK_EYEPATCH},
+  {"raw_ref_op", Feature::Name::RAW_REF_OP},
 }; // namespace Rust
 
 tl::optional<Feature::Name>
index 0fb63b591d43b2661f07e8202e86bdd16fec82c5..6661865aedf1679f93d82d3327f2af69e7450a3e 100644 (file)
@@ -48,6 +48,7 @@ public:
     NO_CORE,
     BOX_SYNTAX,
     DROPCK_EYEPATCH,
+    RAW_REF_OP,
   };
 
   const std::string &as_string () { return m_name_str; }