diff options
| author | bors <bors@rust-lang.org> | 2019-01-05 22:25:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-05 22:25:47 +0000 |
| commit | ad9068f874007e732d59ffef141f3ccd43e43a6b (patch) | |
| tree | d5406cd031b26855632d8bb9ff37fc021111df52 /src/test/ui/liveness | |
| parent | 68fe5182c967259ef89dbe313e4bf80f45a53e7e (diff) | |
| parent | 211365d68c8eb5515cb658c4c240c73c122d2c5e (diff) | |
Auto merge of #57230 - estebank:return-mismatch, r=varkor
Modify mismatched type error for functions with no return
Fix #50009.
```
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:3:24
|
LL | fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
| -------- ^^^ expected i32, found ()
| |
| this function's body doesn't return
LL | x + 1;
| - help: consider removing this semicolon
|
= note: expected type `i32`
found type `()`
```
instead of
```
error[E0308]: mismatched types
--> $DIR/coercion-missing-tail-expected-type.rs:3:28
|
LL | fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
| ____________________________^
LL | | x + 1;
| | - help: consider removing this semicolon
LL | | }
| |_^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
```
Diffstat (limited to 'src/test/ui/liveness')
| -rw-r--r-- | src/test/ui/liveness/liveness-forgot-ret.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/liveness/liveness-missing-ret2.stderr | 13 | ||||
| -rw-r--r-- | src/test/ui/liveness/liveness-return-last-stmt-semi.stderr | 41 |
3 files changed, 30 insertions, 30 deletions
diff --git a/src/test/ui/liveness/liveness-forgot-ret.stderr b/src/test/ui/liveness/liveness-forgot-ret.stderr index b8911225900..bbcbbdbe8dd 100644 --- a/src/test/ui/liveness/liveness-forgot-ret.stderr +++ b/src/test/ui/liveness/liveness-forgot-ret.stderr @@ -1,8 +1,10 @@ error[E0308]: mismatched types - --> $DIR/liveness-forgot-ret.rs:3:25 + --> $DIR/liveness-forgot-ret.rs:3:19 | LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected isize, found () + | - ^^^^^ expected isize, found () - expected because of this statement + | | + | this function's body doesn't return | = note: expected type `isize` found type `()` diff --git a/src/test/ui/liveness/liveness-missing-ret2.stderr b/src/test/ui/liveness/liveness-missing-ret2.stderr index e5f74786bc6..58d0249ee3b 100644 --- a/src/test/ui/liveness/liveness-missing-ret2.stderr +++ b/src/test/ui/liveness/liveness-missing-ret2.stderr @@ -1,13 +1,10 @@ error[E0308]: mismatched types - --> $DIR/liveness-missing-ret2.rs:1:17 + --> $DIR/liveness-missing-ret2.rs:1:11 | -LL | fn f() -> isize { //~ ERROR mismatched types - | _________________^ -LL | | // Make sure typestate doesn't interpret this match expression as -LL | | // the function result -LL | | match true { true => { } _ => {} }; -LL | | } - | |_^ expected isize, found () +LL | fn f() -> isize { //~ ERROR mismatched types + | - ^^^^^ expected isize, found () + | | + | this function's body doesn't return | = note: expected type `isize` found type `()` diff --git a/src/test/ui/liveness/liveness-return-last-stmt-semi.stderr b/src/test/ui/liveness/liveness-return-last-stmt-semi.stderr index 3aa81a405a6..c6d166d8b31 100644 --- a/src/test/ui/liveness/liveness-return-last-stmt-semi.stderr +++ b/src/test/ui/liveness/liveness-return-last-stmt-semi.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/liveness-return-last-stmt-semi.rs:4:45 + --> $DIR/liveness-return-last-stmt-semi.rs:4:41 | LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } } - | ^^^-^^ - | | | - | | help: consider removing this semicolon - | expected i32, found () + | --- ^^^ - help: consider removing this semicolon + | | | + | | expected i32, found () + | this function's body doesn't return ... LL | test!(); | -------- in this macro invocation @@ -14,35 +14,36 @@ LL | test!(); found type `()` error[E0308]: mismatched types - --> $DIR/liveness-return-last-stmt-semi.rs:7:23 + --> $DIR/liveness-return-last-stmt-semi.rs:7:19 | LL | fn no_return() -> i32 {} //~ ERROR mismatched types - | ^^ expected i32, found () + | --------- ^^^ expected i32, found () + | | + | this function's body doesn't return | = note: expected type `i32` found type `()` error[E0308]: mismatched types - --> $DIR/liveness-return-last-stmt-semi.rs:9:23 + --> $DIR/liveness-return-last-stmt-semi.rs:9:19 | -LL | fn bar(x: u32) -> u32 { //~ ERROR mismatched types - | _______________________^ -LL | | x * 2; - | | - help: consider removing this semicolon -LL | | } - | |_^ expected u32, found () +LL | fn bar(x: u32) -> u32 { //~ ERROR mismatched types + | --- ^^^ expected u32, found () + | | + | this function's body doesn't return +LL | x * 2; + | - help: consider removing this semicolon | = note: expected type `u32` found type `()` error[E0308]: mismatched types - --> $DIR/liveness-return-last-stmt-semi.rs:13:23 + --> $DIR/liveness-return-last-stmt-semi.rs:13:19 | -LL | fn baz(x: u64) -> u32 { //~ ERROR mismatched types - | _______________________^ -LL | | x * 2; -LL | | } - | |_^ expected u32, found () +LL | fn baz(x: u64) -> u32 { //~ ERROR mismatched types + | --- ^^^ expected u32, found () + | | + | this function's body doesn't return | = note: expected type `u32` found type `()` |
