updated compiler tests for rustc_intrinsic' · rust-lang/rust@a3669b8 (original) (raw)

File tree

4 files changed

lines changed

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -6,10 +6,9 @@ Erroneous code example:
6 6 #![feature(intrinsics)]
7 7 #![allow(internal_features)]
8 8
9 -extern "rust-intrinsic" {
10 - fn atomic_foo(); // error: unrecognized atomic operation
11 - // function
12 -}
9 +#[rustc_intrinsic]
10 +unsafe fn atomic_foo(); // error: unrecognized atomic operation
11 + // function
13 12 ```
14 13
15 14 Please check you didn't make a mistake in the function's name. All intrinsic
@@ -20,7 +19,6 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
20 19 #![feature(intrinsics)]
21 20 #![allow(internal_features)]
22 21
23 -extern "rust-intrinsic" {
24 - fn atomic_fence_seqcst(); // ok!
25 -}
22 +#[rustc_intrinsic]
23 +unsafe fn atomic_fence_seqcst(); // ok!
26 24 ```
Original file line number Diff line number Diff line change
@@ -6,9 +6,8 @@ Erroneous code example:
6 6 #![feature(intrinsics)]
7 7 #![allow(internal_features)]
8 8
9 -extern "rust-intrinsic" {
10 - fn foo(); // error: unrecognized intrinsic function: `foo`
11 -}
9 +#[rustc_intrinsic]
10 +unsafe fn foo(); // error: unrecognized intrinsic function: `foo`
12 11
13 12 fn main() {
14 13 unsafe {
@@ -25,9 +24,8 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
25 24 #![feature(intrinsics)]
26 25 #![allow(internal_features)]
27 26
28 -extern "rust-intrinsic" {
29 - fn atomic_fence_seqcst(); // ok!
30 -}
27 +#[rustc_intrinsic]
28 +unsafe fn atomic_fence_seqcst(); // ok!
31 29
32 30 fn main() {
33 31 unsafe {
Original file line number Diff line number Diff line change
@@ -7,9 +7,8 @@ used. Erroneous code examples:
7 7 #![feature(intrinsics)]
8 8 #![allow(internal_features)]
9 9
10 -extern "rust-intrinsic" {
11 - fn unreachable(); // error: intrinsic has wrong type
12 -}
10 +#[rustc_intrinsic]
11 +unsafe fn unreachable(); // error: intrinsic has wrong type
13 12
14 13 // or:
15 14
@@ -43,9 +42,8 @@ For the first code example, please check the function definition. Example:
43 42 #![feature(intrinsics)]
44 43 #![allow(internal_features)]
45 44
46 -extern "rust-intrinsic" {
47 - fn unreachable() -> !; // ok!
48 -}
45 +#[rustc_intrinsic]
46 +unsafe fn unreachable() -> !; // ok!
49 47 ```
50 48
51 49 The second case example is a bit particular: the main function must always
Original file line number Diff line number Diff line change
@@ -5,9 +5,8 @@ Erroneous code example:
5 5 ```compile_fail,E0511
6 6 #![feature(intrinsics)]
7 7
8 -extern "rust-intrinsic" {
9 - fn simd_add(a: T, b: T) -> T;
10 -}
8 +#[rustc_intrinsic]
9 +unsafe fn simd_add(a: T, b: T) -> T;
11 10
12 11 fn main() {
13 12 unsafe { simd_add(0, 1); }
@@ -25,9 +24,8 @@ The generic type has to be a SIMD type. Example:
25 24 #[derive(Copy, Clone)]
26 25 struct i32x2([i32; 2]);
27 26
28 -extern "rust-intrinsic" {
29 - fn simd_add(a: T, b: T) -> T;
30 -}
27 +#[rustc_intrinsic]
28 +unsafe fn simd_add(a: T, b: T) -> T;
31 29
32 30 unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
33 31 ```