<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/ui/expr/if/if-else-chain-missing-else.rs, branch beta</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=beta</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=beta'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-01-16T00:18:26+00:00</updated>
<entry>
<title>Detect if-else chains with a missing final else in type errors</title>
<updated>2025-01-16T00:18:26+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2025-01-15T22:09:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f78a1bd89ade0d326a47222e51c61bd631530416'/>
<id>urn:sha1:f78a1bd89ade0d326a47222e51c61bd631530416</id>
<content type='text'>
```
error[E0308]: `if` and `else` have incompatible types
  --&gt; $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.
</content>
</entry>
</feed>
