]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 12 Jun 2024 09:56:01 +0000 (09:56 +0000)
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 847122f70d981230368521ea24f3aa4f05d85761..d5b70635857f9d93328443323ac139ad16d200be 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 5801c0d5da77c295a94e0c13fc025bc5a3b38ac7..0d53b40c151be34c33fe847b9bd8e09f0134a3db 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 0af3209e338ff4bf2e0e6f8e6546d49d280d4d6d..cb2b42cafaf029b566243d7e0d82dabf94cdf4b5 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 abb8c551406ceb7a257d063675032d72f606f784..5a1819912df2cd79587dbe0f7587e365597af2cc 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; }