rust/tests
Dylan DPC 27fa7b5e6d
Rollup merge of #108427 - y21:for-else-diagnostic, r=compiler-errors
Recover from for-else and while-else

This recovers from attempts at writing for-else or while-else loops, which might help users coming from e.g. Python.
```rs
for _ in 0..0 {
  // ...
} else {
  // ...
}
```
Combined with trying to store it in a let binding, the current diagnostic can be a bit confusing. It mentions let-else and suggests wrapping the loop in parentheses, which the user probably doesn't want. let-else doesn't make sense for `for` and `while` loops, as they are of type `()` (which already is an irrefutable pattern and doesn't need let-else).
<details>
<summary>Current diagnostic</summary>

```rs
error: right curly brace `}` before `else` in a `let...else` statement not allowed
 --> src/main.rs:4:5
  |
4 |     } else {
  |     ^
  |
help: wrap the expression in parentheses
  |
2 ~     let _x = (for _ in 0..0 {
3 |
4 ~     }) else {
  |
```
</details>

Some questions:
- Can the wording for the error message be improved? Would "for...else loops are not allowed" fit better?
- Should we be more "conservative" in case we want to support this in the future (i.e. say "for...else loops are **currently** not allowed/supported")?
- Is there a better way than storing a `&'static str` for the loop type? It is used for substituting the placeholder in the locale file (since it can emit either `for...else` or `while...else`). Maybe there is an enum I could use that I couldn't find
2023-03-01 23:40:19 +05:30
..
assembly
auxiliary
codegen Add Option::as_slice(_mut) 2023-03-01 00:05:31 +01:00
codegen-units
debuginfo Remove the capture_disjoint_fields feature 2023-02-28 01:21:15 +00:00
incremental
mir-opt Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank 2023-02-28 01:14:56 +00:00
pretty
run-make errors: fix translation's run-make test 2023-02-22 09:15:54 +00:00
run-make-fulldeps various: translation resources from cg backend 2023-02-22 09:15:54 +00:00
run-pass-valgrind
rustdoc rustdoc: avoid including <li> tags in item table short desc 2023-02-23 13:53:27 -07:00
rustdoc-gui No need for the wait-for anymore to go around browser navigation bug 2023-02-23 22:04:38 +01:00
rustdoc-js rustdoc: search by macro when query ends with ! 2023-02-16 18:16:09 -07:00
rustdoc-js-std Rollup merge of #108143 - notriddle:notriddle/filter-exclamation-macro, r=GuillaumeGomez 2023-03-01 23:40:18 +05:30
rustdoc-json Add regression test for #107677 2023-02-18 18:28:17 +01:00
rustdoc-ui Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgr 2023-02-26 02:04:23 +00:00
ui recover from for-else and while-else 2023-03-01 13:26:59 +01:00
ui-fulldeps Auto merge of #108233 - ChrisDenton:move-std-tests, r=thomcc 2023-02-25 10:26:57 +00:00
COMPILER_TESTS.md