From: Arthur Cohen <[email protected]>
If the Rust version we're targeting is equal or higher than 1.82, then allow
&raw {const,mut}
syntax without feature gating it.
gcc/rust/ChangeLog:
* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit):
Don't gate the feature if
we are in compatibility mode higher or equal to 1.82.
gcc/testsuite/ChangeLog:
* rust/compile/raw-borrow-compat-mode.rs: New test.
---
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/b853d101be5eef25180aeb17281d08c1a03af294
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/5113
gcc/rust/checks/errors/feature/rust-feature-gate.cc | 6 ++++--
gcc/testsuite/rust/compile/raw-borrow-compat-mode.rs | 10 ++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/raw-borrow-compat-mode.rs
diff --git a/gcc/rust/checks/errors/feature/rust-feature-gate.cc
b/gcc/rust/checks/errors/feature/rust-feature-gate.cc
index bea7e1306..54c5621ce 100644
--- a/gcc/rust/checks/errors/feature/rust-feature-gate.cc
+++ b/gcc/rust/checks/errors/feature/rust-feature-gate.cc
@@ -24,6 +24,7 @@
#include "rust-feature.h"
#include "rust-ast-full.h"
#include "rust-feature-store.h"
+#include "rust-session-manager.h"
namespace Rust {
@@ -321,8 +322,9 @@ 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");
+ if (Session::get_instance ().get_compat_version () < 82)
+ gate (Feature::Name::RAW_REF_OP, expr.get_locus (),
+ "raw address of syntax is experimental");
}
void
diff --git a/gcc/testsuite/rust/compile/raw-borrow-compat-mode.rs
b/gcc/testsuite/rust/compile/raw-borrow-compat-mode.rs
new file mode 100644
index 000000000..7b086b342
--- /dev/null
+++ b/gcc/testsuite/rust/compile/raw-borrow-compat-mode.rs
@@ -0,0 +1,10 @@
+#![feature(no_core)]
+#![no_core]
+
+// { dg-additional-options "-frust-compat-version=1.82" }
+
+fn main() {
+ let a = 15;
+ let _ = &raw const a;
+ let _ = &raw mut a;
+}
base-commit: e279095e3837f4d01e53b61928598de303807a26
--
2.56.1