rust/tests/ui/closures/issue-87461.stderr
Robin Schroer a3cf3822d2
Emit a hint for bad call return types due to generic arguments
When the return type of a function call depends on the type of an
argument, e.g.

```
fn foo<T>(x: T) -> T {
    x
}
```

and the expected type is set due to either an explicitly typed
binding, or because the call to the function is in a tail position
without semicolon, the current error implies that the argument in the
call has the wrong type.

This new hint highlights that the expected type doesn't match the
returned type, which matches the argument type, and that that's why
we're flagging the argument type.

Fixes #43608.
2023-01-13 13:34:55 +09:00

58 lines
1.6 KiB
Plaintext

error[E0308]: mismatched types
--> $DIR/issue-87461.rs:10:8
|
LL | Ok(())
| -- ^^ expected `u16`, found `()`
| |
| arguments to this enum variant are incorrect
|
help: the type constructed contains `()` due to the type of the argument passed
--> $DIR/issue-87461.rs:10:5
|
LL | Ok(())
| ^^^--^
| |
| this argument influences the type of `Ok`
note: tuple variant defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
error[E0308]: mismatched types
--> $DIR/issue-87461.rs:17:8
|
LL | Ok(())
| -- ^^ expected `u16`, found `()`
| |
| arguments to this enum variant are incorrect
|
help: the type constructed contains `()` due to the type of the argument passed
--> $DIR/issue-87461.rs:17:5
|
LL | Ok(())
| ^^^--^
| |
| this argument influences the type of `Ok`
note: tuple variant defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
error[E0308]: mismatched types
--> $DIR/issue-87461.rs:26:12
|
LL | Ok(())
| -- ^^ expected `u16`, found `()`
| |
| arguments to this enum variant are incorrect
|
help: the type constructed contains `()` due to the type of the argument passed
--> $DIR/issue-87461.rs:26:9
|
LL | Ok(())
| ^^^--^
| |
| this argument influences the type of `Ok`
note: tuple variant defined here
--> $SRC_DIR/core/src/result.rs:LL:COL
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.