5 files changed +32
-32
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ 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
12
+
13
13
```
14
14
15
15
Please check you didn't make a mistake in the function's name. All intrinsic
@@ -20,7 +20,7 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
20
20
#![feature(intrinsics)]
21
21
#![allow(internal_features)]
22
22
23
- extern "rust-intrinsic" {
24
- fn atomic_fence_seqcst(); // ok!
25
- }
23
+ #[rustc_intrinsic]
24
+ unsafe fn atomic_fence_seqcst(); // ok!
25
+
26
26
```
Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ 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`
11
+
12
12
13
13
fn main() {
14
14
unsafe {
@@ -25,9 +25,9 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
25
25
#![feature(intrinsics)]
26
26
#![allow(internal_features)]
27
27
28
- extern "rust-intrinsic" {
29
- fn atomic_fence_seqcst(); // ok!
30
- }
28
+ #[rustc_intrinsic]
29
+ unsafe fn atomic_fence_seqcst(); // ok!
30
+
31
31
32
32
fn main() {
33
33
unsafe {
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ 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
12
+
13
13
14
14
// or:
15
15
@@ -43,9 +43,9 @@ For the first code example, please check the function definition. Example:
43
43
#![feature(intrinsics)]
44
44
#![allow(internal_features)]
45
45
46
- extern "rust-intrinsic" {
47
- fn unreachable() -> !; // ok!
48
- }
46
+ #[rustc_intrinsic]
47
+ unsafe fn unreachable() -> !; // ok!
48
+
49
49
```
50
50
51
51
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,9 @@ Erroneous code example:
5
5
``` compile_fail,E0511
6
6
#![feature(intrinsics)]
7
7
8
- extern "rust-intrinsic" {
9
- fn simd_add<T>(a : T, b : T) -> T;
10
- }
8
+ #[rustc_intrinsic]
9
+ unsafe fn simd_add<T>(_a : T, _b : T) -> T;
10
+
11
11
12
12
fn main() {
13
13
unsafe { simd_add(0, 1); }
@@ -25,9 +25,9 @@ The generic type has to be a SIMD type. Example:
25
25
#[derive(Copy, Clone)]
26
26
struct i32x2([i32; 2]);
27
27
28
- extern "rust-intrinsic" {
29
- fn simd_add<T>(a : T, b : T) -> T;
30
- }
28
+ #[rustc_intrinsic]
29
+ unsafe fn simd_add<T>(_a : T, _b : T) -> T;
30
+
31
31
32
32
unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
33
33
```
Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ Erroneous code example:
6
6
#![feature(intrinsics)]
7
7
#![allow(internal_features)]
8
8
9
- extern "rust-intrinsic" {
10
- pub static atomic_singlethreadfence_seqcst: fn();
11
- // error: intrinsic must be a function
12
- }
9
+ #[rustc_intrinsic]
10
+ pub static atomic_singlethreadfence_seqcst: fn();
11
+ // error: intrinsic must be a function
12
+
13
13
14
14
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
15
15
```
@@ -22,9 +22,9 @@ error, just declare a function. Example:
22
22
#![feature(intrinsics)]
23
23
#![allow(internal_features)]
24
24
25
- extern "rust-intrinsic" {
26
- pub fn atomic_singlethreadfence_seqcst(); // ok!
27
- }
25
+ #[rustc_intrinsic]
26
+ pub unsafe fn atomic_singlethreadfence_seqcst(); // ok!
27
+
28
28
29
29
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
30
30
```
0 commit comments