Files
rust/tests/ui/macros
Matthias Krüger 12cc9b4b6f Rollup merge of #135044 - compiler-errors:better-infer-suggestions-in-const, r=oli-obk
Improve infer (`_`) suggestions in `const`s and `static`s

Fixes https://github.com/rust-lang/rust/issues/135010.

This PR does a few things to (imo) greatly improve the error message when users write something like `static FOO: [i32; _] = [1, 2, 3]`.

Firstly, it adapts the recovery code for when we encounter `_` in a const/static to work a bit more like `fn foo() -> _`, and removes the somewhat redundant query `diagnostic_only_typeck`.

Secondly, it changes the lowering for `[T; _]` to always lower under the `feature(generic_arg_infer)` logic to `ConstArgKind::Infer`. We still issue the feature error, so it's not doing anything *observable* on the good path, but it does mean that we no longer erroneously interpret `[T; _]`'s array length as a `_` **wildcard expression** (à la destructuring assignment, like `(_, y) = expr`).

Lastly it makes the suggestions verbose and fixes (well, suppresses) a bug with stashing and suggestions.

r? oli-obk
2025-01-03 22:12:45 +01:00
..
2024-12-01 19:10:44 -03:00
2024-10-28 14:20:28 +11:00
2024-10-28 14:20:28 +11:00
2024-02-29 19:06:31 +08:00
2024-03-03 16:30:48 -03:00
2024-03-03 16:30:48 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2023-04-20 15:06:17 -03:00
2024-02-09 15:43:08 -03:00
2024-02-09 15:43:08 -03:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-10-28 14:20:28 +11:00
2024-10-28 14:20:28 +11:00
2024-10-28 14:20:28 +11:00
2024-10-28 14:20:28 +11:00
2024-10-28 14:20:28 +11:00
2024-10-30 16:47:47 -07:00
2024-10-30 16:47:47 -07:00
2024-12-13 00:04:56 +00:00