1
Fork 0

Introduce distinct error codes for precise capturing

This commit is contained in:
Michael Goulet 2024-09-15 17:34:25 -04:00
parent 26bdfefae1
commit ae8b4607c6
10 changed files with 69 additions and 9 deletions

View 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.

View 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.

View file

@ -538,6 +538,8 @@ E0795: 0795,
E0796: 0796,
E0797: 0797,
E0798: 0798,
E0799: 0799,
E0800: 0800,
);
)
}