diff options
| author | bors <bors@rust-lang.org> | 2024-09-16 14:59:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-16 14:59:29 +0000 |
| commit | 3a22be33db27e4f90e95dfaad301af400386efc1 (patch) | |
| tree | 48e337f4cf001bdf9e0de0a28b24942972b36fe7 /compiler/rustc_error_codes/src | |
| parent | 13b5a4e43b92cf738acad403ea56900947f9d37b (diff) | |
| parent | ae8b4607c6c92164dce2e92f9496de189a43bc44 (diff) | |
| download | rust-3a22be33db27e4f90e95dfaad301af400386efc1.tar.gz rust-3a22be33db27e4f90e95dfaad301af400386efc1.zip | |
Auto merge of #130414 - compiler-errors:precise-capturing-arg-valid, r=jieyouxu
Do precise capturing arg validation in resolve Moves the validation of precise capturing args (`use<T, N>`) out of `resolve_bound_vars` and into `rustc_resolve`. This both simplifies the impl and fixes a bug when we have `use<arg>` where `arg` is one of the function args. This also introduces new error codes specifically for precise capturing, to avoid reusing the other error codes which are not as accurate. Fixes #130399
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0799.md | 19 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0800.md | 11 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/lib.rs | 2 |
3 files changed, 32 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0799.md b/compiler/rustc_error_codes/src/error_codes/E0799.md new file mode 100644 index 00000000000..38ebc840604 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0799.md @@ -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. diff --git a/compiler/rustc_error_codes/src/error_codes/E0800.md b/compiler/rustc_error_codes/src/error_codes/E0800.md new file mode 100644 index 00000000000..3e08cd499b7 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0800.md @@ -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. diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs index 150f99a3ee7..d6f0206b0de 100644 --- a/compiler/rustc_error_codes/src/lib.rs +++ b/compiler/rustc_error_codes/src/lib.rs @@ -538,6 +538,8 @@ E0795: 0795, E0796: 0796, E0797: 0797, E0798: 0798, +E0799: 0799, +E0800: 0800, ); ) } |
