diff options
| author | Robin Schroer <git@sulami.xyz> | 2023-01-08 21:10:48 +0900 |
|---|---|---|
| committer | Robin Schroer <git@sulami.xyz> | 2023-01-13 13:34:55 +0900 |
| commit | a3cf3822d267524e3d9fa45309f2718793f3cf7f (patch) | |
| tree | 400f87368a38ea4a2f1acdff0eedd27b719cbec3 /tests/ui/suggestions/args-instead-of-tuple-errors.stderr | |
| parent | 56ee65aeb6d1fad67d903d5ee1359abcf7b94231 (diff) | |
| download | rust-a3cf3822d267524e3d9fa45309f2718793f3cf7f.tar.gz rust-a3cf3822d267524e3d9fa45309f2718793f3cf7f.zip | |
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.
Diffstat (limited to 'tests/ui/suggestions/args-instead-of-tuple-errors.stderr')
| -rw-r--r-- | tests/ui/suggestions/args-instead-of-tuple-errors.stderr | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr index 44a39efdf25..bc097bf6eb4 100644 --- a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr +++ b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr @@ -11,6 +11,13 @@ LL | let _: Option<(i32, bool)> = Some(1, 2); | ^ = note: expected tuple `(i32, bool)` found type `{integer}` +help: the type constructed contains `{integer}` due to the type of the argument passed + --> $DIR/args-instead-of-tuple-errors.rs:6:34 + | +LL | let _: Option<(i32, bool)> = Some(1, 2); + | ^^^^^-^^^^ + | | + | this argument influences the type of `Some` note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL help: remove the extra argument @@ -64,6 +71,13 @@ LL | let _: Option<(i32,)> = Some(5_usize); | = note: expected tuple `(i32,)` found type `usize` +help: the type constructed contains `usize` due to the type of the argument passed + --> $DIR/args-instead-of-tuple-errors.rs:14:29 + | +LL | let _: Option<(i32,)> = Some(5_usize); + | ^^^^^-------^ + | | + | this argument influences the type of `Some` note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL @@ -77,6 +91,13 @@ LL | let _: Option<(i32,)> = Some((5_usize)); | = note: expected tuple `(i32,)` found type `usize` +help: the type constructed contains `usize` due to the type of the argument passed + --> $DIR/args-instead-of-tuple-errors.rs:17:29 + | +LL | let _: Option<(i32,)> = Some((5_usize)); + | ^^^^^---------^ + | | + | this argument influences the type of `Some` note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL |
