Rollup merge of #138364 - BLANKatGITHUB:compiler, r=RalfJung

ports the compiler test cases to new rust_intrinsic format

pr is part of #132735
This commit is contained in:
Matthias Krüger 2025-03-21 15:48:51 +01:00 committed by GitHub
commit f7f287077b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 25 deletions

View file

@ -6,10 +6,9 @@ Erroneous code example:
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn atomic_foo(); // error: unrecognized atomic operation
// function
}
#[rustc_intrinsic]
unsafe fn atomic_foo(); // error: unrecognized atomic operation
// function
```
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
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn atomic_fence_seqcst(); // ok!
}
#[rustc_intrinsic]
unsafe fn atomic_fence_seqcst(); // ok!
```

View file

@ -6,9 +6,8 @@ Erroneous code example:
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn foo(); // error: unrecognized intrinsic function: `foo`
}
#[rustc_intrinsic]
unsafe fn foo(); // error: unrecognized intrinsic function: `foo`
fn main() {
unsafe {
@ -25,9 +24,8 @@ functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn atomic_fence_seqcst(); // ok!
}
#[rustc_intrinsic]
unsafe fn atomic_fence_seqcst(); // ok!
fn main() {
unsafe {

View file

@ -7,9 +7,8 @@ used. Erroneous code examples:
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn unreachable(); // error: intrinsic has wrong type
}
#[rustc_intrinsic]
unsafe fn unreachable(); // error: intrinsic has wrong type
// or:
@ -43,9 +42,8 @@ For the first code example, please check the function definition. Example:
#![feature(intrinsics)]
#![allow(internal_features)]
extern "rust-intrinsic" {
fn unreachable() -> !; // ok!
}
#[rustc_intrinsic]
unsafe fn unreachable() -> !; // ok!
```
The second case example is a bit particular: the main function must always

View file

@ -5,9 +5,8 @@ Erroneous code example:
```compile_fail,E0511
#![feature(intrinsics)]
extern "rust-intrinsic" {
fn simd_add<T>(a: T, b: T) -> T;
}
#[rustc_intrinsic]
unsafe fn simd_add<T>(a: T, b: T) -> T;
fn main() {
unsafe { simd_add(0, 1); }
@ -25,9 +24,8 @@ The generic type has to be a SIMD type. Example:
#[derive(Copy, Clone)]
struct i32x2([i32; 2]);
extern "rust-intrinsic" {
fn simd_add<T>(a: T, b: T) -> T;
}
#[rustc_intrinsic]
unsafe fn simd_add<T>(a: T, b: T) -> T;
unsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!
```