Point at return type when appropriate

This commit is contained in:
Esteban Küber 2019-01-18 00:12:09 -08:00
parent 954769e2ed
commit 2e06d9c91b
8 changed files with 30 additions and 5 deletions

View file

@ -1,6 +1,8 @@
error[E0308]: mismatched types
--> $DIR/fully-qualified-type-name2.rs:12:12
|
LL | fn bar(x: x::Foo) -> y::Foo {
| ------ expected `y::Foo` because of return type
LL | return x;
| ^ expected enum `y::Foo`, found enum `x::Foo`
|

View file

@ -1,6 +1,8 @@
error[E0308]: mismatched types
--> $DIR/fully-qualified-type-name4.rs:6:12
|
LL | fn bar(x: usize) -> Option<usize> {
| ------------- expected `std::option::Option<usize>` because of return type
LL | return x;
| ^ expected enum `std::option::Option`, found usize
|

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/liveness-forgot-ret.rs:3:19
|
LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; }
| - ^^^^^ expected isize, found () - expected because of this statement
| - ^^^^^ expected isize, found ()
| |
| this function's body doesn't return
|

View file

@ -15,6 +15,9 @@ LL | let x: usize = "hello";;;;; //~ ERROR mismatched types
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:19:29
|
LL | fn b(x: Option<isize>) -> usize {
| ----- expected `usize` because of return type
LL | match x {
LL | Some(x) => { return x }, //~ ERROR mismatched types
| ^ expected usize, found isize

View file

@ -1,6 +1,8 @@
error[E0308]: mismatched types
--> $DIR/return-from-diverging.rs:4:12
|
LL | fn fail() -> ! {
| - expected `!` because of return type
LL | return "wow"; //~ ERROR mismatched types
| ^^^^^ expected !, found reference
|

View file

@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/tail-typeck.rs:3:26
|
LL | fn f() -> isize { return g(); }
| ^^^ expected isize, found usize
| ----- ^^^ expected isize, found usize
| |
| expected `isize` because of return type
error: aborting due to previous error

View file

@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/wrong-ret-type.rs:2:49
|
LL | fn mk_int() -> usize { let i: isize = 3; return i; }
| ^ expected usize, found isize
| ----- ^ expected usize, found isize
| |
| expected `usize` because of return type
error: aborting due to previous error