-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #86148 - FabianWolff:issue-85855, r=varkor
Check the number of generic lifetime and const parameters of intrinsics This pull request fixes #85855. The current code for type checking intrinsics only checks the number of generic _type_ parameters, but does not check for an incorrect number of lifetime or const parameters, which can cause problems later on, such as the ICE in #85855, where the code thought that it was looking at a type parameter but found a lifetime parameter: ``` error: internal compiler error: compiler/rustc_middle/src/ty/generics.rs:188:18: expected type parameter, but found another generic parameter ``` The changes in this PR add checks for the number of lifetime and const parameters, expand the scope of `E0094` to also apply to these cases, and improve the error message by properly pluralizing the number of expected generic parameters.
- Loading branch information
Showing
5 changed files
with
81 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 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) -> T; | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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 type parameters: found 2, expected 1 | ||
--> $DIR/issue-85855.rs:14: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:17:16 | ||
| | ||
LL | fn simd_mul<T, const N: usize>(x: T, y: T); | ||
| ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0094`. |