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-27 19:58:16 +11:00
2024-12-12 23:36:27 +00:00
2024-11-27 07:18:25 -08:00
2024-12-27 19:58:16 +11:00
2025-01-02 23:39:17 +00:00
2024-12-23 22:15:32 +00:00
2024-12-22 14:49:01 +08:00
2024-12-27 11:44:23 +01:00
2024-12-01 08:15:25 +01:00
2024-12-30 14:56:21 +07:00
2025-01-02 23:39:16 +00:00
2024-12-27 19:58:16 +11:00
2024-12-07 21:37:13 +00:00
2024-11-27 07:18:25 -08:00
2024-12-05 23:52:21 +00:00
2025-01-01 15:58:29 +01:00
2024-12-04 20:29:36 +00:00
2024-12-07 21:37:13 +00:00
2024-12-20 02:38:46 +08:00
2024-12-31 02:21:17 +00:00
2024-12-02 18:43:37 +01:00
2024-12-31 02:21:17 +00:00
2024-12-07 21:37:13 +00:00
2024-11-30 12:56:54 +08:00
2024-11-27 07:18:25 -08:00
2025-01-02 16:49:55 +01:00
2024-12-31 15:11:18 +08:00
2024-11-27 22:21:33 +01:00
2024-12-27 19:58:16 +11:00
2024-12-12 23:36:27 +00:00
2024-12-12 23:36:27 +00:00
2024-12-07 21:26:20 +00:00
2024-12-28 13:57:13 +11:00
2024-12-04 20:29:35 +00:00
2025-01-03 22:12:45 +01:00
2024-12-27 19:58:16 +11:00
2025-01-03 22:12:45 +01:00
2024-12-31 15:11:18 +08:00
2024-12-25 19:23:48 +11:00
2024-12-27 19:58:16 +11:00
2024-12-02 18:43:37 +01:00
2024-12-09 21:06:29 +08:00
2024-12-27 12:42:07 +11:00
2024-11-27 07:18:25 -08:00
2024-12-04 20:34:48 +08:00
2024-12-09 21:55:01 +00:00
2024-12-18 07:10:55 +01:00
2024-12-10 11:29:43 +08:00
2024-12-27 19:58:16 +11:00
2024-12-23 20:25:41 +00:00
2024-12-07 21:29:58 +00:00
2024-12-31 23:46:39 +08:00
2025-01-02 19:16:00 +01:00
2024-12-22 21:59:27 +01:00
2024-12-15 20:28:16 -08:00
2024-12-09 15:17:26 +01:00
2025-01-02 23:39:17 +00:00
2024-12-26 17:41:43 +00:00
2024-12-27 19:58:16 +11:00
2024-12-23 22:15:32 +00:00
2024-12-12 23:36:27 +00:00
2025-01-01 15:58:29 +01:00
2025-01-02 23:39:16 +00:00
2024-12-30 06:14:26 -08:00
2024-12-12 23:36:27 +00:00
2024-12-19 10:56:31 +00:00
2024-12-12 23:36:27 +00:00
2025-01-02 23:39:16 +00:00
2024-12-13 13:07:07 +01:00
2024-12-31 02:21:17 +00:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2025-01-01 19:32:51 +00:00
2024-12-27 19:58:16 +11:00
2024-12-31 23:46:39 +08:00
2024-12-31 23:46:39 +08:00
2024-12-31 23:46:39 +08:00
2024-12-27 19:58:16 +11:00
2024-11-27 07:18:25 -08:00
2024-12-04 20:49:05 +00:00
2024-12-17 13:56:10 +11:00
2025-01-01 15:58:29 +01:00
2024-12-27 19:58:16 +11:00
2024-12-30 19:10:43 +08:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2024-12-15 20:28:16 -08:00
2024-12-07 21:29:58 +00:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2024-12-07 21:29:58 +00:00
2024-12-13 14:18:41 -08:00
2024-12-14 03:54:31 +01:00
2024-12-27 19:58:16 +11:00
2024-12-31 02:25:35 +00:00
2024-12-07 13:18:05 +11:00
2024-12-27 19:58:16 +11:00
2024-12-12 23:36:27 +00:00
2024-12-27 19:58:16 +11:00
2024-12-12 23:36:27 +00:00
2025-01-03 22:12:45 +01:00
2024-12-31 18:42:23 -05:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2024-12-07 18:18:08 +00:00
2024-12-07 21:29:58 +00:00
2024-12-27 19:58:16 +11:00
2024-12-31 18:42:23 -05:00
2024-12-15 20:28:16 -08:00
2024-12-31 18:42:23 -05:00
2024-12-12 23:36:27 +00:00
2024-12-27 19:58:16 +11:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2025-01-02 23:39:16 +00:00
2024-12-31 18:42:23 -05:00
2024-12-27 19:58:16 +11:00
2024-12-12 23:36:27 +00:00
2025-01-01 15:58:29 +01:00
2025-01-01 15:58:29 +01:00
2024-12-09 21:55:12 +00:00
2024-12-14 06:44:05 +00:00
2024-12-24 19:12:13 +00:00
2024-12-27 19:58:16 +11:00
2024-12-27 19:58:16 +11:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2024-12-12 23:36:27 +00:00
2024-12-27 19:58:16 +11:00
2024-12-28 11:19:16 +08:00
2024-11-27 07:18:25 -08:00
2024-11-27 07:18:25 -08:00
2024-12-15 20:28:16 -08:00
2024-12-17 13:56:10 +11:00
2024-12-13 00:04:56 +00:00
2024-12-21 01:30:16 +01:00
2024-12-03 07:48:33 +01:00
2024-12-13 15:40:37 +00:00
2024-12-15 04:45:24 +00:00
2024-12-12 23:36:27 +00:00
2024-12-14 22:43:39 +00:00
2024-12-23 22:15:32 +00:00
2024-12-27 19:58:16 +11:00
2025-01-01 19:32:51 +00:00
2024-12-08 15:32:04 +08:00
2024-12-31 18:06:01 +00:00
2024-12-16 14:59:10 -05:00
2025-01-02 23:39:17 +00:00
2024-12-27 19:58:16 +11:00
2024-12-27 19:58:16 +11:00
2024-12-15 19:14:24 +00:00
2025-01-01 15:58:29 +01:00
2024-12-09 21:55:01 +00:00
2024-12-25 10:36:32 +01:00
2024-12-23 20:25:41 +00:00
2025-01-01 15:58:29 +01:00
2024-12-07 22:18:51 +00:00
2025-01-03 06:40:28 +00:00
2024-12-12 23:36:27 +00:00
2024-12-27 19:58:16 +11:00
2025-01-01 15:58:29 +01:00
2024-12-07 21:29:58 +00:00
2024-12-27 19:58:16 +11:00
2024-12-07 21:37:15 +00:00
2024-12-14 03:54:31 +01:00
2025-01-03 22:12:45 +01:00
2024-12-13 15:40:37 +00:00
2024-11-27 07:18:25 -08:00
2024-12-07 21:37:13 +00:00
2024-12-18 19:27:44 +00:00
2024-12-07 21:37:13 +00:00
2024-12-27 19:58:16 +11:00
2024-12-15 20:28:16 -08:00
2024-12-22 21:57:57 +00:00
2024-12-07 20:50:00 +00:00
2024-12-06 16:42:09 -05:00
2024-12-07 21:29:58 +00:00
2024-12-07 21:29:58 +00:00
2024-12-12 23:36:27 +00:00
2024-12-27 19:58:16 +11:00
2024-11-28 14:32:45 -08:00
2024-12-07 21:29:58 +00:00
2024-12-02 03:43:50 -07:00
2024-12-27 19:58:16 +11:00