462f06de07
Fixes #66910 We have several different kinds of suggestions we can try to make when type coercion fails. However, we were previously only emitting these suggestions from `demand_coerce_diag`. This resulted in the compiler failing to emit applicable suggestions in several different cases, such as when the implicit return value of a function had the wrong type. This commit adds a new `emit_coerce_suggestions` method, which tries to emit a number of related suggestions. This method is called from both `demand_coerce_diag` and `CoerceMany::coerce_inner`, which covers a much wider range of cases than before. We now suggest using `.await` in more cases where it is applicable, among other improvements.
21 lines
524 B
Plaintext
21 lines
524 B
Plaintext
error[E0308]: try expression alternatives have incompatible types
|
|
--> $DIR/issue-59756.rs:13:5
|
|
|
|
|
LL | foo()?
|
|
| ^^^^^^ expected enum `std::result::Result`, found struct `A`
|
|
|
|
|
= note: expected enum `std::result::Result<A, B>`
|
|
found struct `A`
|
|
help: try removing this `?`
|
|
|
|
|
LL | foo()
|
|
| --
|
|
help: try using a variant of the expected enum
|
|
|
|
|
LL | Ok(foo()?)
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0308`.
|