Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8600a0d

Browse files
committedMar 12, 2025
updated compiler tests for rustc_intrinsic'
1 parent ebf0cf7 commit 8600a0d

File tree

5 files changed

+22
-32
lines changed

5 files changed

+22
-32
lines changed
 

‎compiler/rustc_error_codes/src/error_codes/E0092.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ Erroneous code example:
66
#![feature(intrinsics)]
77
#![allow(internal_features)]
88
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
1312
```
1413

1514
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
2019
#![feature(intrinsics)]
2120
#![allow(internal_features)]
2221
23-
extern "rust-intrinsic" {
24-
fn atomic_fence_seqcst(); // ok!
25-
}
22+
#[rustc_intrinsic]
23+
unsafe fn atomic_fence_seqcst(); // ok!
2624
```

‎compiler/rustc_error_codes/src/error_codes/E0093.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ Erroneous code example:
66
#![feature(intrinsics)]
77
#![allow(internal_features)]
88
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`
1211
1312
fn main() {
1413
unsafe {
@@ -25,9 +24,8 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
2524
#![feature(intrinsics)]
2625
#![allow(internal_features)]
2726
28-
extern "rust-intrinsic" {
29-
fn atomic_fence_seqcst(); // ok!
30-
}
27+
#[rustc_intrinsic]
28+
unsafe fn atomic_fence_seqcst(); // ok!
3129
3230
fn main() {
3331
unsafe {

‎compiler/rustc_error_codes/src/error_codes/E0211.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ used. Erroneous code examples:
77
#![feature(intrinsics)]
88
#![allow(internal_features)]
99
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
1312
1413
// or:
1514
@@ -43,9 +42,8 @@ For the first code example, please check the function definition. Example:
4342
#![feature(intrinsics)]
4443
#![allow(internal_features)]
4544
46-
extern "rust-intrinsic" {
47-
fn unreachable() -> !; // ok!
48-
}
45+
#[rustc_intrinsic]
46+
unsafe fn unreachable() -> !; // ok!
4947
```
5048

5149
The second case example is a bit particular: the main function must always

‎compiler/rustc_error_codes/src/error_codes/E0511.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ Erroneous code example:
55
```compile_fail,E0511
66
#![feature(intrinsics)]
77
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;
1110
1211
fn main() {
1312
unsafe { simd_add(0, 1); }
@@ -25,9 +24,8 @@ The generic type has to be a SIMD type. Example:
2524
#[derive(Copy, Clone)]
2625
struct i32x2([i32; 2]);
2726
28-
extern "rust-intrinsic" {
29-
fn simd_add<T>(a: T, b: T) -> T;
30-
}
27+
#[rustc_intrinsic]
28+
unsafe fn simd_add<T>(a: T, b: T) -> T;
3129
3230
unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
3331
```

‎compiler/rustc_error_codes/src/error_codes/E0622.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ Erroneous code example:
66
#![feature(intrinsics)]
77
#![allow(internal_features)]
88
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
1312
1413
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
1514
```
@@ -22,9 +21,8 @@ error, just declare a function. Example:
2221
#![feature(intrinsics)]
2322
#![allow(internal_features)]
2423
25-
extern "rust-intrinsic" {
26-
pub fn atomic_singlethreadfence_seqcst(); // ok!
27-
}
24+
#[rustc_intrinsic]
25+
pub unsafe fn atomic_singlethreadfence_seqcst(); // ok!
2826
2927
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
3028
```

0 commit comments

Comments
 (0)
Failed to load comments.