rust/tests/ui/expr/if
Esteban Küber f78a1bd89a Detect if-else chains with a missing final else in type errors
```
error[E0308]: `if` and `else` have incompatible types
  --> $DIR/if-else-chain-missing-else.rs:12:12
   |
LL |        let x = if let Ok(x) = res {
   |  ______________-
LL | |          x
   | |          - expected because of this
LL | |      } else if let Err(e) = res {
   | | ____________^
LL | ||         return Err(e);
LL | ||     };
   | ||     ^
   | ||_____|
   |  |_____`if` and `else` have incompatible types
   |        expected `i32`, found `()`
   |
   = note: `if` expressions without `else` evaluate to `()`
   = note: consider adding an `else` block that evaluates to the expected type
```

We probably want a longer explanation and fewer spans on this case.

Partially address #133316.
2025-01-16 00:18:26 +00:00
..
attrs Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
bad-if-let-suggestion.rs Suggest let or == on typo'd let-chain 2023-11-28 18:07:52 +00:00
bad-if-let-suggestion.stderr Suggest let or == on typo'd let-chain 2023-11-28 18:07:52 +00:00
expr-if-panic-fn.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
expr-if-panic-pass.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
expr-if-panic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
expr-if.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-branch-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-branch-types.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
if-check-panic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-check.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-cond-bot.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-else-chain-missing-else.rs Detect if-else chains with a missing final else in type errors 2025-01-16 00:18:26 +00:00
if-else-chain-missing-else.stderr Detect if-else chains with a missing final else in type errors 2025-01-16 00:18:26 +00:00
if-else-type-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-else-type-mismatch.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-let-arm-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-let-arm-types.stderr Tweak multispan rendering 2024-12-12 23:36:27 +00:00
if-let.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-let.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-loop.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-no-match-bindings.rs Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
if-no-match-bindings.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
if-ret.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
if-ret.stderr tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
if-typeck.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
if-typeck.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
if-without-block.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-without-block.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
if-without-else-as-fn-expr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-without-else-as-fn-expr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-without-else-result.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if-without-else-result.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-4201.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-4201.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00