Introduce distinct error codes for precise capturing
This commit is contained in:
parent
26bdfefae1
commit
ae8b4607c6
10 changed files with 69 additions and 9 deletions
19
compiler/rustc_error_codes/src/error_codes/E0799.md
Normal file
19
compiler/rustc_error_codes/src/error_codes/E0799.md
Normal file
|
@ -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.
|
11
compiler/rustc_error_codes/src/error_codes/E0800.md
Normal file
11
compiler/rustc_error_codes/src/error_codes/E0800.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
A type 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.
|
|
@ -538,6 +538,8 @@ E0795: 0795,
|
|||
E0796: 0796,
|
||||
E0797: 0797,
|
||||
E0798: 0798,
|
||||
E0799: 0799,
|
||||
E0800: 0800,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue