[committed,65/88] gccrs: Add feature gate for "rust-intrinsic".

Message ID 20230405140411.3016563-66-arthur.cohen@embecosm.com
State Accepted
Headers
Series [committed,01/88] gccrs: fatal_error_flag: Fix typo in error message |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Arthur Cohen April 5, 2023, 2:03 p.m. UTC
  From: mxlol233 <mxlol233@outlook.com>

This commit implemented a feature gate to check `intrinsics`.

gcc/rust/ChangeLog:

	* checks/errors/rust-feature-gate.cc: Add implementation for
	`void FeatureGate::visit (AST::ExternBlock &block)`. Add `valid_feature`
	construction process in `FeatureGate::check`.
	* checks/errors/rust-feature-gate.h: Add declaration for
	`void FeatureGate::visit (AST::ExternBlock &block)`. Add private
	variable `valid_feature`.
	* checks/errors/rust-feature.h: Change `issue` to `m_issue`.

gcc/testsuite/ChangeLog:

	* rust/compile/const-issue1440.rs: Add crate feature: `intrinsics`.
	* rust/compile/feature_intrinsics.rs: New file.
	* rust/compile/issue-1031.rs: Add crate feature: `intrinsics`.
	* rust/compile/issue-1130.rs: Add crate feature: `intrinsics`.
	* rust/compile/issue-1131.rs: Add crate feature: `intrinsics`.
	* rust/compile/issue-1237.rs: Add crate feature: `intrinsics`.
	* rust/compile/issue-1289.rs: Add crate feature: `intrinsics`.
	* rust/compile/rust-const-blog-issue.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/intrinsics-3.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/intrinsics-4.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/intrinsics-5.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/intrinsics-6.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/intrinsics-7.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/issue-1024.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/issue-1075.rs: Add crate feature: `intrinsics`.
	* rust/compile/torture/issue-1432.rs: Add crate feature: `intrinsics`.
	* rust/compile/unsafe10.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/atomic_load.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/atomic_store.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/copy_nonoverlapping1.rs: Add crate feature:
	`intrinsics`.
	* rust/execute/torture/issue-1120.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/issue-1133.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/issue-1232.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/slice-magic.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/slice-magic2.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/str-layout1.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/transmute1.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/wrapping_op1.rs: Add crate feature: `intrinsics`.
	* rust/execute/torture/wrapping_op2.rs: Add crate feature: `intrinsics`.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
---
 gcc/rust/checks/errors/rust-feature-gate.cc   | 61 ++++++++++++++++---
 gcc/rust/checks/errors/rust-feature-gate.h    |  7 ++-
 gcc/rust/checks/errors/rust-feature.h         |  5 +-
 gcc/testsuite/rust/compile/const-issue1440.rs |  1 +
 .../rust/compile/feature_intrinsics.rs        |  7 +++
 gcc/testsuite/rust/compile/issue-1031.rs      |  2 +
 gcc/testsuite/rust/compile/issue-1130.rs      |  2 +
 gcc/testsuite/rust/compile/issue-1131.rs      |  2 +
 gcc/testsuite/rust/compile/issue-1237.rs      |  2 +
 gcc/testsuite/rust/compile/issue-1289.rs      |  2 +
 .../rust/compile/rust-const-blog-issue.rs     |  2 +
 .../rust/compile/torture/intrinsics-3.rs      |  2 +
 .../rust/compile/torture/intrinsics-4.rs      |  2 +
 .../rust/compile/torture/intrinsics-5.rs      |  2 +
 .../rust/compile/torture/intrinsics-6.rs      |  2 +
 .../rust/compile/torture/intrinsics-7.rs      |  2 +
 .../rust/compile/torture/issue-1024.rs        |  2 +
 .../rust/compile/torture/issue-1075.rs        |  2 +
 .../rust/compile/torture/issue-1432.rs        |  1 +
 gcc/testsuite/rust/compile/unsafe10.rs        |  2 +
 .../rust/execute/torture/atomic_load.rs       |  2 +
 .../rust/execute/torture/atomic_store.rs      |  2 +
 .../execute/torture/copy_nonoverlapping1.rs   |  2 +
 .../rust/execute/torture/issue-1120.rs        |  2 +
 .../rust/execute/torture/issue-1133.rs        |  2 +
 .../rust/execute/torture/issue-1232.rs        |  2 +
 .../rust/execute/torture/slice-magic.rs       |  2 +
 .../rust/execute/torture/slice-magic2.rs      |  2 +
 .../rust/execute/torture/str-layout1.rs       |  2 +
 .../rust/execute/torture/transmute1.rs        |  1 +
 .../rust/execute/torture/wrapping_op1.rs      |  2 +
 .../rust/execute/torture/wrapping_op2.rs      |  2 +
 32 files changed, 122 insertions(+), 11 deletions(-)
 create mode 100644 gcc/testsuite/rust/compile/feature_intrinsics.rs
  

Patch

diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc
index 31ce3679ee1..bd01b52c7ff 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.cc
+++ b/gcc/rust/checks/errors/rust-feature-gate.cc
@@ -17,14 +17,15 @@ 
 // <http://www.gnu.org/licenses/>.
 
 #include "rust-feature-gate.h"
-#include "rust-feature.h"
+#include "rust-abi.h"
 
 namespace Rust {
 
 void
 FeatureGate::check (AST::Crate &crate)
 {
-  std::vector<Feature> valid_features;
+  valid_features.clear ();
+
   for (const auto &attr : crate.inner_attrs)
     {
       if (attr.get_path ().as_string () == "feature")
@@ -39,20 +40,22 @@  FeatureGate::check (AST::Crate &crate)
 		option.parse_to_meta_item ());
 	      for (const auto &item : meta_item->get_items ())
 		{
-		  const auto &name = item->as_string ();
-		  auto tname = Feature::as_name (name);
+		  const auto &name_str = item->as_string ();
+		  auto tname = Feature::as_name (name_str);
 		  if (!tname.is_none ())
-		    valid_features.push_back (Feature::create (tname.get ()));
+		    {
+		      auto name = tname.get ();
+		      valid_features.insert (name);
+		    }
+
 		  else
 		    rust_error_at (item->get_locus (), "unknown feature '%s'",
-				   name.c_str ());
+				   name_str.c_str ());
 		}
 	    }
 	}
     }
-  valid_features.shrink_to_fit ();
 
-  // TODO (mxlol233): add the real feature gate stuff.
   auto &items = crate.items;
   for (auto it = items.begin (); it != items.end (); it++)
     {
@@ -60,4 +63,46 @@  FeatureGate::check (AST::Crate &crate)
       item->accept_vis (*this);
     }
 }
+
+void
+FeatureGate::gate (Feature::Name name, Location loc,
+		   const std::string &error_msg)
+{
+  if (!valid_features.count (name))
+    {
+      auto feature = Feature::create (name);
+      auto issue = feature.issue ();
+      if (issue > 0)
+	{
+	  const char *fmt_str
+	    = "%s. see issue %ld "
+	      "<https://github.com/rust-lang/rust/issues/%ld> for more "
+	      "information. add `#![feature(%s)]` to the crate attributes to "
+	      "enable.";
+	  rust_error_at (loc, fmt_str, error_msg.c_str (), issue, issue,
+			 feature.as_string ().c_str ());
+	}
+      else
+	{
+	  const char *fmt_str
+	    = "%s. add `#![feature(%s)]` to the crate attributes to enable.";
+	  rust_error_at (loc, fmt_str, error_msg.c_str (),
+			 feature.as_string ().c_str ());
+	}
+    }
+}
+
+void
+FeatureGate::visit (AST::ExternBlock &block)
+{
+  if (block.has_abi ())
+    {
+      const auto abi = block.get_abi ();
+
+      if (get_abi_from_string (abi) == ABI::INTRINSIC)
+	gate (Feature::Name::INTRINSICS, block.get_locus (),
+	      "intrinsics are subject to change");
+    }
+}
+
 } // namespace Rust
\ No newline at end of file
diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h
index dc95c6b3879..6768c4c2498 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.h
+++ b/gcc/rust/checks/errors/rust-feature-gate.h
@@ -21,6 +21,7 @@ 
 
 #include "rust-ast-visitor.h"
 #include "rust-ast-full.h"
+#include "rust-feature.h"
 
 namespace Rust {
 
@@ -136,7 +137,7 @@  public:
   void visit (AST::TraitImpl &impl) override {}
   void visit (AST::ExternalStaticItem &item) override {}
   void visit (AST::ExternalFunctionItem &item) override {}
-  void visit (AST::ExternBlock &block) override {}
+  void visit (AST::ExternBlock &block) override;
   void visit (AST::MacroMatchFragment &match) override {}
   void visit (AST::MacroMatchRepetition &match) override {}
   void visit (AST::MacroMatcher &matcher) override {}
@@ -186,6 +187,10 @@  public:
   void visit (AST::SliceType &type) override {}
   void visit (AST::InferredType &type) override {}
   void visit (AST::BareFunctionType &type) override {}
+
+private:
+  void gate (Feature::Name name, Location loc, const std::string &error_msg);
+  std::set<Feature::Name> valid_features;
 };
 } // namespace Rust
 #endif
\ No newline at end of file
diff --git a/gcc/rust/checks/errors/rust-feature.h b/gcc/rust/checks/errors/rust-feature.h
index 1425e26cd9a..7bd76c093f2 100644
--- a/gcc/rust/checks/errors/rust-feature.h
+++ b/gcc/rust/checks/errors/rust-feature.h
@@ -47,6 +47,7 @@  public:
   Name name () { return m_name; }
   const std::string &description () { return m_description; }
   State state () { return m_state; }
+  uint64_t issue () { return m_issue; }
 
   static Optional<Name> as_name (const std::string &name);
   static Feature create (Name name);
@@ -57,7 +58,7 @@  private:
 	   const Optional<CompileOptions::Edition> &edition,
 	   const char *description)
     : m_state (state), m_name (name), m_name_str (name_str),
-      m_rustc_since (rustc_since), issue (issue_number), edition (edition),
+      m_rustc_since (rustc_since), m_issue (issue_number), edition (edition),
       m_description (description)
   {}
 
@@ -65,7 +66,7 @@  private:
   Name m_name;
   std::string m_name_str;
   std::string m_rustc_since;
-  uint64_t issue;
+  uint64_t m_issue;
   Optional<CompileOptions::Edition> edition;
   std::string m_description;
 
diff --git a/gcc/testsuite/rust/compile/const-issue1440.rs b/gcc/testsuite/rust/compile/const-issue1440.rs
index 9b974b96bbb..9ad76a96b2a 100644
--- a/gcc/testsuite/rust/compile/const-issue1440.rs
+++ b/gcc/testsuite/rust/compile/const-issue1440.rs
@@ -1,4 +1,5 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
 
 mod intrinsics {
     extern "rust-intrinsic" {
diff --git a/gcc/testsuite/rust/compile/feature_intrinsics.rs b/gcc/testsuite/rust/compile/feature_intrinsics.rs
new file mode 100644
index 00000000000..5eb7ffed864
--- /dev/null
+++ b/gcc/testsuite/rust/compile/feature_intrinsics.rs
@@ -0,0 +1,7 @@ 
+
+extern "rust-intrinsic" { //{ dg-error "intrinsics are subject to change." "" { target *-*-* }  }
+    pub fn sqrtf32(x: f32) -> f32;
+}
+
+fn main() {
+}
diff --git a/gcc/testsuite/rust/compile/issue-1031.rs b/gcc/testsuite/rust/compile/issue-1031.rs
index 5ba8f7a267b..a9049de96fb 100644
--- a/gcc/testsuite/rust/compile/issue-1031.rs
+++ b/gcc/testsuite/rust/compile/issue-1031.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/compile/issue-1130.rs b/gcc/testsuite/rust/compile/issue-1130.rs
index 92200c7cd5f..6d265cb6044 100644
--- a/gcc/testsuite/rust/compile/issue-1130.rs
+++ b/gcc/testsuite/rust/compile/issue-1130.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 mod mem {
     extern "rust-intrinsic" {
         fn size_of<T>() -> usize;
diff --git a/gcc/testsuite/rust/compile/issue-1131.rs b/gcc/testsuite/rust/compile/issue-1131.rs
index fd158abc700..5cb9caf81f0 100644
--- a/gcc/testsuite/rust/compile/issue-1131.rs
+++ b/gcc/testsuite/rust/compile/issue-1131.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     fn size_of<T>() -> usize;
     fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/compile/issue-1237.rs b/gcc/testsuite/rust/compile/issue-1237.rs
index 542be897949..54a51df156f 100644
--- a/gcc/testsuite/rust/compile/issue-1237.rs
+++ b/gcc/testsuite/rust/compile/issue-1237.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 mod intrinsics {
     extern "rust-intrinsic" {
         pub fn offset<T>(ptr: *const T, count: isize) -> *const T;
diff --git a/gcc/testsuite/rust/compile/issue-1289.rs b/gcc/testsuite/rust/compile/issue-1289.rs
index eb41af0a75b..3d7716a1d8c 100644
--- a/gcc/testsuite/rust/compile/issue-1289.rs
+++ b/gcc/testsuite/rust/compile/issue-1289.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "C" {
     fn printf(s: *const i8, ...);
 }
diff --git a/gcc/testsuite/rust/compile/rust-const-blog-issue.rs b/gcc/testsuite/rust/compile/rust-const-blog-issue.rs
index a5ea2ebacb9..679a2ae8c2b 100644
--- a/gcc/testsuite/rust/compile/rust-const-blog-issue.rs
+++ b/gcc/testsuite/rust/compile/rust-const-blog-issue.rs
@@ -1,4 +1,6 @@ 
 // { dg-excess-errors "accessing value of"  }
+#![feature(intrinsics)]
+
 mod mem {
     extern "rust-intrinsic" {
         #[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-3.rs b/gcc/testsuite/rust/compile/torture/intrinsics-3.rs
index 5c131bd8aa2..1601ab6d5b7 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-3.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-3.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     fn not_an_intrinsic();
 }
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-4.rs b/gcc/testsuite/rust/compile/torture/intrinsics-4.rs
index 4e09f1089b0..1f6c0d6608a 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-4.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-4.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-5.rs b/gcc/testsuite/rust/compile/torture/intrinsics-5.rs
index ffad0bd3a85..7a62cca280c 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-5.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-5.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-6.rs b/gcc/testsuite/rust/compile/torture/intrinsics-6.rs
index 143b62a2b27..4e510e11087 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-6.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-6.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn unchecked_add<T>(x: T, y: T) -> T;
     pub fn unchecked_sub<T>(x: T, y: T) -> T;
diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-7.rs b/gcc/testsuite/rust/compile/torture/intrinsics-7.rs
index 8e8c5fe0cdf..da85fff5cd6 100644
--- a/gcc/testsuite/rust/compile/torture/intrinsics-7.rs
+++ b/gcc/testsuite/rust/compile/torture/intrinsics-7.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn unchecked_add<T>(x: T, y: T) -> T;
     // { dg-error "unchecked operation intrinsics can only be used with basic integer types .got .NotAdd.." "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/rust/compile/torture/issue-1024.rs b/gcc/testsuite/rust/compile/torture/issue-1024.rs
index 109540934a8..a8503cebf53 100644
--- a/gcc/testsuite/rust/compile/torture/issue-1024.rs
+++ b/gcc/testsuite/rust/compile/torture/issue-1024.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn size_of<T>() -> usize;
 }
diff --git a/gcc/testsuite/rust/compile/torture/issue-1075.rs b/gcc/testsuite/rust/compile/torture/issue-1075.rs
index 7c0a0434262..201a241d45d 100644
--- a/gcc/testsuite/rust/compile/torture/issue-1075.rs
+++ b/gcc/testsuite/rust/compile/torture/issue-1075.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/compile/torture/issue-1432.rs b/gcc/testsuite/rust/compile/torture/issue-1432.rs
index 083a369d16f..822ca41c5ad 100644
--- a/gcc/testsuite/rust/compile/torture/issue-1432.rs
+++ b/gcc/testsuite/rust/compile/torture/issue-1432.rs
@@ -1,4 +1,5 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
 mod intrinsics {
     extern "rust-intrinsic" {
         #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
diff --git a/gcc/testsuite/rust/compile/unsafe10.rs b/gcc/testsuite/rust/compile/unsafe10.rs
index 6b6be06b908..927e69728c9 100644
--- a/gcc/testsuite/rust/compile/unsafe10.rs
+++ b/gcc/testsuite/rust/compile/unsafe10.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn rotate_left<T>(l: T, r: T) -> T;
 }
diff --git a/gcc/testsuite/rust/execute/torture/atomic_load.rs b/gcc/testsuite/rust/execute/torture/atomic_load.rs
index 6e7383aa7e9..b66c4641424 100644
--- a/gcc/testsuite/rust/execute/torture/atomic_load.rs
+++ b/gcc/testsuite/rust/execute/torture/atomic_load.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/gcc/testsuite/rust/execute/torture/atomic_store.rs b/gcc/testsuite/rust/execute/torture/atomic_store.rs
index 46960a7a186..dcbb2a90f19 100644
--- a/gcc/testsuite/rust/execute/torture/atomic_store.rs
+++ b/gcc/testsuite/rust/execute/torture/atomic_store.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 #[lang = "sized"]
 pub trait Sized {}
 
diff --git a/gcc/testsuite/rust/execute/torture/copy_nonoverlapping1.rs b/gcc/testsuite/rust/execute/torture/copy_nonoverlapping1.rs
index 2ae7a0869e3..39afd3424a4 100644
--- a/gcc/testsuite/rust/execute/torture/copy_nonoverlapping1.rs
+++ b/gcc/testsuite/rust/execute/torture/copy_nonoverlapping1.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
 }
diff --git a/gcc/testsuite/rust/execute/torture/issue-1120.rs b/gcc/testsuite/rust/execute/torture/issue-1120.rs
index 242c94b5cb6..59792b29a29 100644
--- a/gcc/testsuite/rust/execute/torture/issue-1120.rs
+++ b/gcc/testsuite/rust/execute/torture/issue-1120.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/execute/torture/issue-1133.rs b/gcc/testsuite/rust/execute/torture/issue-1133.rs
index f2080a6e072..8679bb93224 100644
--- a/gcc/testsuite/rust/execute/torture/issue-1133.rs
+++ b/gcc/testsuite/rust/execute/torture/issue-1133.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/execute/torture/issue-1232.rs b/gcc/testsuite/rust/execute/torture/issue-1232.rs
index 9215efdba6c..ce53da2d033 100644
--- a/gcc/testsuite/rust/execute/torture/issue-1232.rs
+++ b/gcc/testsuite/rust/execute/torture/issue-1232.rs
@@ -1,5 +1,7 @@ 
 // { dg-additional-options "-w" }
 // { dg-output "slice_access=3\r*\n" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/execute/torture/slice-magic.rs b/gcc/testsuite/rust/execute/torture/slice-magic.rs
index d1132989ddb..b52aa3df510 100644
--- a/gcc/testsuite/rust/execute/torture/slice-magic.rs
+++ b/gcc/testsuite/rust/execute/torture/slice-magic.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/execute/torture/slice-magic2.rs b/gcc/testsuite/rust/execute/torture/slice-magic2.rs
index 64a566185fa..cdc39f3dcca 100644
--- a/gcc/testsuite/rust/execute/torture/slice-magic2.rs
+++ b/gcc/testsuite/rust/execute/torture/slice-magic2.rs
@@ -1,4 +1,6 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     #[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
diff --git a/gcc/testsuite/rust/execute/torture/str-layout1.rs b/gcc/testsuite/rust/execute/torture/str-layout1.rs
index 39c1e38d77b..c9bcf1631e2 100644
--- a/gcc/testsuite/rust/execute/torture/str-layout1.rs
+++ b/gcc/testsuite/rust/execute/torture/str-layout1.rs
@@ -1,5 +1,7 @@ 
 // { dg-additional-options "-w" }
 // { dg-output "t1sz=5 t2sz=10\r*" }
+#![feature(intrinsics)]
+
 mod mem {
     extern "rust-intrinsic" {
         #[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
diff --git a/gcc/testsuite/rust/execute/torture/transmute1.rs b/gcc/testsuite/rust/execute/torture/transmute1.rs
index b9ec38ca618..40dcfdee0b3 100644
--- a/gcc/testsuite/rust/execute/torture/transmute1.rs
+++ b/gcc/testsuite/rust/execute/torture/transmute1.rs
@@ -1,4 +1,5 @@ 
 // { dg-additional-options "-w" }
+#![feature(intrinsics)]
 
 extern "rust-intrinsic" {
     fn transmute<T, U>(value: T) -> U;
diff --git a/gcc/testsuite/rust/execute/torture/wrapping_op1.rs b/gcc/testsuite/rust/execute/torture/wrapping_op1.rs
index 64b37085ab7..ab4afd7ddde 100644
--- a/gcc/testsuite/rust/execute/torture/wrapping_op1.rs
+++ b/gcc/testsuite/rust/execute/torture/wrapping_op1.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn wrapping_add<T>(l: T, r: T) -> T;
 }
diff --git a/gcc/testsuite/rust/execute/torture/wrapping_op2.rs b/gcc/testsuite/rust/execute/torture/wrapping_op2.rs
index f9990157894..b24ebce56f1 100644
--- a/gcc/testsuite/rust/execute/torture/wrapping_op2.rs
+++ b/gcc/testsuite/rust/execute/torture/wrapping_op2.rs
@@ -1,3 +1,5 @@ 
+#![feature(intrinsics)]
+
 extern "rust-intrinsic" {
     pub fn wrapping_add<T>(l: T, r: T) -> T;
     pub fn wrapping_sub<T>(l: T, r: T) -> T;