-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Report an error if a lang item has the wrong number of generic arguments #85339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,20 @@ | ||
// Checks whether declaring a lang item with the wrong number | ||
// of generic arguments crashes the compiler (issue #83893). | ||
|
||
#![feature(lang_items,no_core)] | ||
#![no_core] | ||
#![crate_type="lib"] | ||
|
||
#[lang = "sized"] | ||
trait MySized {} | ||
|
||
#[lang = "add"] | ||
trait MyAdd<'a, T> {} | ||
//~^^ ERROR: `add` language item must be applied to a trait with 1 generic argument [E0718] | ||
|
||
fn ice() { | ||
let r = 5; | ||
let a = 6; | ||
r + a | ||
//~^ ERROR: cannot add `{integer}` to `{integer}` [E0369] | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/ui/lang-items/wrong-number-generic-args-add.stderr
This file contains hidden or 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,20 @@ | ||
error[E0718]: `add` language item must be applied to a trait with 1 generic argument | ||
--> $DIR/wrong-number-generic-args-add.rs:11:1 | ||
| | ||
LL | #[lang = "add"] | ||
| ^^^^^^^^^^^^^^^ | ||
LL | trait MyAdd<'a, T> {} | ||
| ------- this trait has 2 generic arguments, not 1 | ||
|
||
error[E0369]: cannot add `{integer}` to `{integer}` | ||
--> $DIR/wrong-number-generic-args-add.rs:18:7 | ||
| | ||
LL | r + a | ||
| - ^ - {integer} | ||
| | | ||
| {integer} | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0369, E0718. | ||
For more information about an error, try `rustc --explain E0369`. |
This file contains hidden or 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 @@ | ||
// Checks whether declaring a lang item with the wrong number | ||
// of generic arguments crashes the compiler (issue #83893). | ||
|
||
#![feature(lang_items,no_core)] | ||
#![no_core] | ||
#![crate_type="lib"] | ||
|
||
#[lang = "sized"] | ||
trait MySized {} | ||
|
||
#[lang = "index"] | ||
trait MyIndex<'a, T> {} | ||
//~^^ ERROR: `index` language item must be applied to a trait with 1 generic argument [E0718] | ||
|
||
fn ice() { | ||
let arr = [0; 5]; | ||
let _ = arr[2]; | ||
//~^ ERROR: cannot index into a value of type `[{integer}; 5]` [E0608] | ||
} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/lang-items/wrong-number-generic-args-index.stderr
This file contains hidden or 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,18 @@ | ||
error[E0718]: `index` language item must be applied to a trait with 1 generic argument | ||
--> $DIR/wrong-number-generic-args-index.rs:11:1 | ||
| | ||
LL | #[lang = "index"] | ||
| ^^^^^^^^^^^^^^^^^ | ||
LL | trait MyIndex<'a, T> {} | ||
| ------- this trait has 2 generic arguments, not 1 | ||
|
||
error[E0608]: cannot index into a value of type `[{integer}; 5]` | ||
--> $DIR/wrong-number-generic-args-index.rs:17:13 | ||
| | ||
LL | let _ = arr[2]; | ||
| ^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0608, E0718. | ||
For more information about an error, try `rustc --explain E0608`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.