Account for tail expressions when pointing at return type

When there's a type mismatch we make an effort to check if it was
caused by a function's return type. This logic now makes sure to
only point at the return type if the error happens in a tail
expression.
This commit is contained in:
Esteban Küber 2019-09-25 23:01:01 -07:00
parent faee8e1756
commit 46a38dc183
4 changed files with 31 additions and 7 deletions

View file

@ -49,9 +49,6 @@ LL | if x == E::V { field } {}
error[E0308]: mismatched types
--> $DIR/struct-literal-variant-in-if.rs:10:20
|
LL | fn test_E(x: E) {
| - help: try adding a return type: `-> bool`
LL | let field = true;
LL | if x == E::V { field } {}
| ^^^^^ expected (), found bool
|