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 d4190be

Browse files
committedMar 1, 2025
ported compiler test cases to #[rust_intrinsic]
1 parent 0c72c0d commit d4190be

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed
 

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ 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
12+
1313
```
1414

1515
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
2020
#![feature(intrinsics)]
2121
#![allow(internal_features)]
2222
23-
extern "rust-intrinsic" {
24-
fn atomic_fence_seqcst(); // ok!
25-
}
23+
#[rustc_intrinsic]
24+
unsafe fn atomic_fence_seqcst(); // ok!
25+
2626
```

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ 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`
11+
1212
1313
fn main() {
1414
unsafe {
@@ -25,9 +25,9 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
2525
#![feature(intrinsics)]
2626
#![allow(internal_features)]
2727
28-
extern "rust-intrinsic" {
29-
fn atomic_fence_seqcst(); // ok!
30-
}
28+
#[rustc_intrinsic]
29+
unsafe fn atomic_fence_seqcst(); // ok!
30+
3131
3232
fn main() {
3333
unsafe {

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ 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
12+
1313
1414
// or:
1515
@@ -43,9 +43,9 @@ For the first code example, please check the function definition. Example:
4343
#![feature(intrinsics)]
4444
#![allow(internal_features)]
4545
46-
extern "rust-intrinsic" {
47-
fn unreachable() -> !; // ok!
48-
}
46+
#[rustc_intrinsic]
47+
unsafe fn unreachable() -> !; // ok!
48+
4949
```
5050

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

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ 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;
10+
1111
1212
fn main() {
1313
unsafe { simd_add(0, 1); }
@@ -25,9 +25,9 @@ The generic type has to be a SIMD type. Example:
2525
#[derive(Copy, Clone)]
2626
struct i32x2([i32; 2]);
2727
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+
3131
3232
unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
3333
```

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ 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
12+
1313
1414
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
1515
```
@@ -22,9 +22,9 @@ error, just declare a function. Example:
2222
#![feature(intrinsics)]
2323
#![allow(internal_features)]
2424
25-
extern "rust-intrinsic" {
26-
pub fn atomic_singlethreadfence_seqcst(); // ok!
27-
}
25+
#[rustc_intrinsic]
26+
pub unsafe fn atomic_singlethreadfence_seqcst(); // ok!
27+
2828
2929
fn main() { unsafe { atomic_singlethreadfence_seqcst(); } }
3030
```

0 commit comments

Comments
 (0)
Failed to load comments.