about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-11-07 08:59:43 +0100
committerRalf Jung <post@ralfj.de>2024-11-08 09:16:00 +0100
commite3010e84dbf2e06424c91c5a3d4206c1911813bd (patch)
treee79c95932b5c88f5313d5eb5e45b3c3c41ed7b9f /tests
parent78bb5ee79e0261e8e47476b631da02acc1cb03ef (diff)
downloadrust-e3010e84dbf2e06424c91c5a3d4206c1911813bd.tar.gz
rust-e3010e84dbf2e06424c91c5a3d4206c1911813bd.zip
remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead
Diffstat (limited to 'tests')
-rw-r--r--tests/assembly/rust-abi-arg-attr.rs7
-rw-r--r--tests/rustdoc/safe-intrinsic.rs25
-rw-r--r--tests/ui/error-codes/E0094.rs13
-rw-r--r--tests/ui/error-codes/E0094.stderr6
-rw-r--r--tests/ui/error-codes/E0308.rs11
-rw-r--r--tests/ui/error-codes/E0308.stderr10
-rw-r--r--tests/ui/extern/extern-with-type-bounds.rs11
-rw-r--r--tests/ui/extern/extern-with-type-bounds.stderr2
-rw-r--r--tests/ui/intrinsics/always-gets-overridden.rs2
-rw-r--r--tests/ui/intrinsics/feature-gate-safe-intrinsic.rs6
-rw-r--r--tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr21
-rw-r--r--tests/ui/intrinsics/intrinsic-alignment.rs10
-rw-r--r--tests/ui/intrinsics/intrinsics-integer.rs22
-rw-r--r--tests/ui/intrinsics/not-overridden.rs2
-rw-r--r--tests/ui/structs-enums/rec-align-u32.rs15
-rw-r--r--tests/ui/structs-enums/rec-align-u64.rs15
16 files changed, 58 insertions, 120 deletions
diff --git a/tests/assembly/rust-abi-arg-attr.rs b/tests/assembly/rust-abi-arg-attr.rs
index 2a113eed4ba..e55a53fbdeb 100644
--- a/tests/assembly/rust-abi-arg-attr.rs
+++ b/tests/assembly/rust-abi-arg-attr.rs
@@ -50,9 +50,10 @@ enum Ordering {
     Greater = 1,
 }
 
-extern "rust-intrinsic" {
-    #[rustc_safe_intrinsic]
-    fn three_way_compare<T: Copy>(lhs: T, rhs: T) -> Ordering;
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+fn three_way_compare<T: Copy>(lhs: T, rhs: T) -> Ordering {
+    loop {}
 }
 
 // ^^^^^ core
diff --git a/tests/rustdoc/safe-intrinsic.rs b/tests/rustdoc/safe-intrinsic.rs
index b46ffed99c3..07af04ace60 100644
--- a/tests/rustdoc/safe-intrinsic.rs
+++ b/tests/rustdoc/safe-intrinsic.rs
@@ -5,18 +5,17 @@
 #![no_core]
 #![crate_name = "foo"]
 
-extern "rust-intrinsic" {
-    //@ has 'foo/fn.abort.html'
-    //@ has - '//pre[@class="rust item-decl"]' 'pub extern "rust-intrinsic" fn abort() -> !'
-    #[rustc_safe_intrinsic]
-    pub fn abort() -> !;
-    //@ has 'foo/fn.unreachable.html'
-    //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !'
-    pub fn unreachable() -> !;
+//@ has 'foo/fn.abort.html'
+//@ has - '//pre[@class="rust item-decl"]' 'pub fn abort() -> !'
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub fn abort() -> ! {
+    loop {}
 }
-
-extern "C" {
-    //@ has 'foo/fn.needs_drop.html'
-    //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn needs_drop() -> !'
-    pub fn needs_drop() -> !;
+//@ has 'foo/fn.unreachable.html'
+//@ has - '//pre[@class="rust item-decl"]' 'pub unsafe fn unreachable() -> !'
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub unsafe fn unreachable() -> ! {
+    loop {}
 }
diff --git a/tests/ui/error-codes/E0094.rs b/tests/ui/error-codes/E0094.rs
index 97ebcff99dc..da59d3decac 100644
--- a/tests/ui/error-codes/E0094.rs
+++ b/tests/ui/error-codes/E0094.rs
@@ -1,9 +1,10 @@
-#![feature(intrinsics, rustc_attrs)]
+#![feature(intrinsics)]
 
-extern "rust-intrinsic" {
-    #[rustc_safe_intrinsic]
-    fn size_of<T, U>() -> usize; //~ ERROR E0094
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+fn size_of<T, U>() -> usize {
+    //~^ ERROR E0094
+    loop {}
 }
 
-fn main() {
-}
+fn main() {}
diff --git a/tests/ui/error-codes/E0094.stderr b/tests/ui/error-codes/E0094.stderr
index 1bad5bd950e..e45cc0ea063 100644
--- a/tests/ui/error-codes/E0094.stderr
+++ b/tests/ui/error-codes/E0094.stderr
@@ -1,8 +1,8 @@
 error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1
-  --> $DIR/E0094.rs:5:15
+  --> $DIR/E0094.rs:5:11
    |
-LL |     fn size_of<T, U>() -> usize;
-   |               ^^^^^^ expected 1 type parameter
+LL | fn size_of<T, U>() -> usize {
+   |           ^^^^^^ expected 1 type parameter
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/error-codes/E0308.rs b/tests/ui/error-codes/E0308.rs
index dd9e0b284ea..f8f93d49a8e 100644
--- a/tests/ui/error-codes/E0308.rs
+++ b/tests/ui/error-codes/E0308.rs
@@ -1,10 +1,11 @@
 #![feature(intrinsics)]
 #![feature(rustc_attrs)]
 
-extern "rust-intrinsic" {
-    #[rustc_safe_intrinsic]
-    fn size_of<T>(); //~ ERROR E0308
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+fn size_of<T>() {
+    //~^ ERROR E0308
+    loop {}
 }
 
-fn main() {
-}
+fn main() {}
diff --git a/tests/ui/error-codes/E0308.stderr b/tests/ui/error-codes/E0308.stderr
index 709b3119276..77e5c06e06a 100644
--- a/tests/ui/error-codes/E0308.stderr
+++ b/tests/ui/error-codes/E0308.stderr
@@ -1,11 +1,11 @@
 error[E0308]: intrinsic has wrong type
-  --> $DIR/E0308.rs:6:20
+  --> $DIR/E0308.rs:6:16
    |
-LL |     fn size_of<T>();
-   |                    ^ expected `usize`, found `()`
+LL | fn size_of<T>() {
+   |                ^ expected `usize`, found `()`
    |
-   = note: expected signature `extern "rust-intrinsic" fn() -> usize`
-              found signature `extern "rust-intrinsic" fn() -> ()`
+   = note: expected signature `fn() -> usize`
+              found signature `fn() -> ()`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/extern/extern-with-type-bounds.rs b/tests/ui/extern/extern-with-type-bounds.rs
index 99e9801fd40..3fbddfc99a6 100644
--- a/tests/ui/extern/extern-with-type-bounds.rs
+++ b/tests/ui/extern/extern-with-type-bounds.rs
@@ -1,18 +1,17 @@
 #![feature(intrinsics, rustc_attrs)]
 
-extern "rust-intrinsic" {
-    // Real example from libcore
-    #[rustc_safe_intrinsic]
-    fn type_id<T: ?Sized + 'static>() -> u64;
+// Intrinsics are the only (?) extern blocks supporting generics.
+// Once intrinsics have to be declared via `#[rustc_intrinsic]`,
+// the entire support for generics in extern fn can probably be removed.
 
+extern "rust-intrinsic" {
     // Silent bounds made explicit to make sure they are actually
     // resolved.
     fn transmute<T: Sized, U: Sized>(val: T) -> U;
 
     // Bounds aren't checked right now, so this should work
     // even though it's incorrect.
-    #[rustc_safe_intrinsic]
-    fn size_of<T: Clone>() -> usize;
+    fn size_of_val<T: Clone>(x: *const T) -> usize;
 
     // Unresolved bounds should still error.
     fn align_of<T: NoSuchTrait>() -> usize;
diff --git a/tests/ui/extern/extern-with-type-bounds.stderr b/tests/ui/extern/extern-with-type-bounds.stderr
index 42448d9e924..893947e831f 100644
--- a/tests/ui/extern/extern-with-type-bounds.stderr
+++ b/tests/ui/extern/extern-with-type-bounds.stderr
@@ -1,5 +1,5 @@
 error[E0405]: cannot find trait `NoSuchTrait` in this scope
-  --> $DIR/extern-with-type-bounds.rs:18:20
+  --> $DIR/extern-with-type-bounds.rs:17:20
    |
 LL |     fn align_of<T: NoSuchTrait>() -> usize;
    |                    ^^^^^^^^^^^ not found in this scope
diff --git a/tests/ui/intrinsics/always-gets-overridden.rs b/tests/ui/intrinsics/always-gets-overridden.rs
index ad2c2be4daa..2fb64f96d83 100644
--- a/tests/ui/intrinsics/always-gets-overridden.rs
+++ b/tests/ui/intrinsics/always-gets-overridden.rs
@@ -1,6 +1,6 @@
 //! Check that `vtable_size` gets overridden by llvm backend even if there is no
 //! `rustc_intrinsic_must_be_overridden` attribute on this usage.
-#![feature(rustc_attrs)]
+#![feature(intrinsics)]
 //@run-pass
 
 #[rustc_intrinsic]
diff --git a/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs b/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs
deleted file mode 100644
index ffaa4d771d9..00000000000
--- a/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#[rustc_safe_intrinsic]
-//~^ ERROR the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe
-//~| ERROR attribute should be applied to intrinsic functions
-fn safe() {}
-
-fn main() {}
diff --git a/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr b/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr
deleted file mode 100644
index e49880e9bb8..00000000000
--- a/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0658]: the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe
-  --> $DIR/feature-gate-safe-intrinsic.rs:1:1
-   |
-LL | #[rustc_safe_intrinsic]
-   | ^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: attribute should be applied to intrinsic functions
-  --> $DIR/feature-gate-safe-intrinsic.rs:1:1
-   |
-LL | #[rustc_safe_intrinsic]
-   | ^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | fn safe() {}
-   | ------------ not an intrinsic function
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/intrinsics/intrinsic-alignment.rs b/tests/ui/intrinsics/intrinsic-alignment.rs
index 4cb05f6a8df..ab99aa5fd03 100644
--- a/tests/ui/intrinsics/intrinsic-alignment.rs
+++ b/tests/ui/intrinsics/intrinsic-alignment.rs
@@ -1,14 +1,8 @@
 //@ run-pass
 
-#![feature(intrinsics, rustc_attrs)]
+#![feature(core_intrinsics, rustc_attrs)]
 
-mod rusti {
-    extern "rust-intrinsic" {
-        pub fn pref_align_of<T>() -> usize;
-        #[rustc_safe_intrinsic]
-        pub fn min_align_of<T>() -> usize;
-    }
-}
+use std::intrinsics as rusti;
 
 #[cfg(any(
     target_os = "android",
diff --git a/tests/ui/intrinsics/intrinsics-integer.rs b/tests/ui/intrinsics/intrinsics-integer.rs
index 7dbc4b8b7ce..8eb03924feb 100644
--- a/tests/ui/intrinsics/intrinsics-integer.rs
+++ b/tests/ui/intrinsics/intrinsics-integer.rs
@@ -1,24 +1,8 @@
 //@ run-pass
 
-#![feature(intrinsics)]
-#![feature(rustc_attrs)]
-
-mod rusti {
-    extern "rust-intrinsic" {
-        #[rustc_safe_intrinsic]
-        pub fn ctpop<T>(x: T) -> u32;
-        #[rustc_safe_intrinsic]
-        pub fn ctlz<T>(x: T) -> u32;
-        pub fn ctlz_nonzero<T>(x: T) -> u32;
-        #[rustc_safe_intrinsic]
-        pub fn cttz<T>(x: T) -> u32;
-        pub fn cttz_nonzero<T>(x: T) -> u32;
-        #[rustc_safe_intrinsic]
-        pub fn bswap<T>(x: T) -> T;
-        #[rustc_safe_intrinsic]
-        pub fn bitreverse<T>(x: T) -> T;
-    }
-}
+#![feature(core_intrinsics)]
+
+use std::intrinsics as rusti;
 
 pub fn main() {
     use rusti::*;
diff --git a/tests/ui/intrinsics/not-overridden.rs b/tests/ui/intrinsics/not-overridden.rs
index e1f1bbe0951..16f8e9bcf6a 100644
--- a/tests/ui/intrinsics/not-overridden.rs
+++ b/tests/ui/intrinsics/not-overridden.rs
@@ -1,6 +1,6 @@
 //! Check that intrinsics that do not get overridden, but are marked as such,
 //! cause an error instead of silently invoking the body.
-#![feature(rustc_attrs)]
+#![feature(intrinsics)]
 //@ build-fail
 //@ failure-status:101
 //@ normalize-stderr-test: ".*note: .*\n\n" -> ""
diff --git a/tests/ui/structs-enums/rec-align-u32.rs b/tests/ui/structs-enums/rec-align-u32.rs
index 9cd2a988871..44879189739 100644
--- a/tests/ui/structs-enums/rec-align-u32.rs
+++ b/tests/ui/structs-enums/rec-align-u32.rs
@@ -3,17 +3,10 @@
 #![allow(unused_unsafe)]
 // Issue #2303
 
-#![feature(intrinsics, rustc_attrs)]
+#![feature(core_intrinsics, rustc_attrs)]
 
 use std::mem;
-
-mod rusti {
-    extern "rust-intrinsic" {
-        pub fn pref_align_of<T>() -> usize;
-        #[rustc_safe_intrinsic]
-        pub fn min_align_of<T>() -> usize;
-    }
-}
+use std::intrinsics;
 
 // This is the type with the questionable alignment
 #[derive(Debug)]
@@ -41,12 +34,12 @@ pub fn main() {
         // Send it through the shape code
         let y = format!("{:?}", x);
 
-        println!("align inner = {:?}", rusti::min_align_of::<Inner>());
+        println!("align inner = {:?}", intrinsics::min_align_of::<Inner>());
         println!("size outer = {:?}", mem::size_of::<Outer>());
         println!("y = {:?}", y);
 
         // per clang/gcc the alignment of `inner` is 4 on x86.
-        assert_eq!(rusti::min_align_of::<Inner>(), m::align());
+        assert_eq!(intrinsics::min_align_of::<Inner>(), m::align());
 
         // per clang/gcc the size of `outer` should be 12
         // because `inner`s alignment was 4.
diff --git a/tests/ui/structs-enums/rec-align-u64.rs b/tests/ui/structs-enums/rec-align-u64.rs
index 313ce6d578d..8b501ea5509 100644
--- a/tests/ui/structs-enums/rec-align-u64.rs
+++ b/tests/ui/structs-enums/rec-align-u64.rs
@@ -4,17 +4,10 @@
 
 // Issue #2303
 
-#![feature(intrinsics, rustc_attrs)]
+#![feature(core_intrinsics, rustc_attrs)]
 
 use std::mem;
-
-mod rusti {
-    extern "rust-intrinsic" {
-        pub fn pref_align_of<T>() -> usize;
-        #[rustc_safe_intrinsic]
-        pub fn min_align_of<T>() -> usize;
-    }
-}
+use std::intrinsics;
 
 // This is the type with the questionable alignment
 #[derive(Debug)]
@@ -90,12 +83,12 @@ pub fn main() {
 
         let y = format!("{:?}", x);
 
-        println!("align inner = {:?}", rusti::min_align_of::<Inner>());
+        println!("align inner = {:?}", intrinsics::min_align_of::<Inner>());
         println!("size outer = {:?}", mem::size_of::<Outer>());
         println!("y = {:?}", y);
 
         // per clang/gcc the alignment of `Inner` is 4 on x86.
-        assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
+        assert_eq!(intrinsics::min_align_of::<Inner>(), m::m::align());
 
         // per clang/gcc the size of `Outer` should be 12
         // because `Inner`s alignment was 4.