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 7e624c5

Browse files
authoredMar 21, 2025
Rollup merge of rust-lang#138364 - BLANKatGITHUB:compiler, r=RalfJung
ports the compiler test cases to new rust_intrinsic format pr is part of rust-lang#132735
2 parents 01dc45c + a3669b8 commit 7e624c5

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
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
```

0 commit comments

Comments
 (0)
Failed to load comments.