-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce distinct error codes for precise capturing
- Loading branch information
1 parent
9d1af81
commit 10af205
Showing
10 changed files
with
69 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Something other than a type or const parameter has been used when one was | ||
expected. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0799 | ||
fn bad1() -> impl Sized + use<main> {} | ||
fn bad2(x: ()) -> impl Sized + use<x> {} | ||
fn main() {} | ||
``` | ||
|
||
In the given examples, for `bad1`, the name `main` corresponds to a function | ||
rather than a type or const parameter. In `bad2`, the name `x` corresponds to | ||
a function argument rather than a type or const parameter. | ||
|
||
Only type and const parameters, including `Self`, may be captured by | ||
`use<...>` precise capturing bounds. |
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,11 @@ | ||
Atype or const parameter of the given name is not in scope. | ||
|
||
Erroneous code examples: | ||
|
||
```compile_fail,E0800 | ||
fn missing() -> impl Sized + use<T> {} | ||
``` | ||
|
||
To fix this error, please verify you didn't misspell the type or const | ||
parameter, or double-check if you forgot to declare the parameter in | ||
the list of generics. |
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 |
---|---|---|
|
@@ -538,6 +538,8 @@ E0795: 0795, | |
E0796: 0796, | ||
E0797: 0797, | ||
E0798: 0798, | ||
E0799: 0799, | ||
E0800: 0800, | ||
); | ||
) | ||
} | ||
|
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,4 @@ | ||
fn test() -> impl Sized + use<main> {} | ||
//~^ ERROR E0799 | ||
|
||
fn main() {} |
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,9 @@ | ||
error[E0799]: expected type or const parameter, found function `main` | ||
--> $DIR/E0799.rs:1:31 | ||
| | ||
LL | fn test() -> impl Sized + use<main> {} | ||
| ^^^^ not a type or const parameter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0799`. |
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,4 @@ | ||
fn test() -> impl Sized + use<Missing> {} | ||
//~^ ERROR E0800 | ||
|
||
fn main() {} |
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,9 @@ | ||
error[E0800]: cannot find type or const parameter `Missing` in this scope | ||
--> $DIR/E0800.rs:1:31 | ||
| | ||
LL | fn test() -> impl Sized + use<Missing> {} | ||
| ^^^^^^^ not found in this scope | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0800`. |
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