Check the number of generic lifetime and const parameters of intrinsics

This commit is contained in:
Fabian Wolff 2021-06-08 20:38:43 +02:00
parent a50d72158e
commit 7b2befc27b
5 changed files with 117 additions and 29 deletions

View file

@ -0,0 +1,20 @@
// Check that appropriate errors are reported if an intrinsic is defined
// with the wrong number of generic lifetime/type/const parameters, and
// that no ICE occurs in these cases.
#![feature(platform_intrinsics)]
#![crate_type="lib"]
extern "platform-intrinsic" {
fn simd_saturating_add<'a, T: 'a>(x: T, y: T);
//~^ ERROR: intrinsic has wrong number of lifetime parameters
fn simd_add<'a, T>(x: T, y: T);
//~^ ERROR: intrinsic has wrong number of lifetime parameters
fn simd_sub<T, U>(x: T, y: U);
//~^ ERROR: intrinsic has wrong number of type parameters
fn simd_mul<T, const N: usize>(x: T, y: T);
//~^ ERROR: intrinsic has wrong number of const parameters
}

View file

@ -0,0 +1,27 @@
error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0
--> $DIR/issue-85855.rs:9:27
|
LL | fn simd_saturating_add<'a, T: 'a>(x: T, y: T);
| ^^^^^^^^^^^ expected 0 lifetime parameters
error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0
--> $DIR/issue-85855.rs:12:16
|
LL | fn simd_add<'a, T>(x: T, y: T);
| ^^^^^^^ expected 0 lifetime parameters
error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1
--> $DIR/issue-85855.rs:15:16
|
LL | fn simd_sub<T, U>(x: T, y: U);
| ^^^^^^ expected 1 type parameter
error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0
--> $DIR/issue-85855.rs:18:16
|
LL | fn simd_mul<T, const N: usize>(x: T, y: T);
| ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0094`.