]> git.lizzy.rs Git - rust.git/commit
Auto merge of #57230 - estebank:return-mismatch, r=varkor
authorbors <bors@rust-lang.org>
Sat, 5 Jan 2019 22:25:47 +0000 (22:25 +0000)
committerbors <bors@rust-lang.org>
Sat, 5 Jan 2019 22:25:47 +0000 (22:25 +0000)
commitad9068f874007e732d59ffef141f3ccd43e43a6b
treed5406cd031b26855632d8bb9ff37fc021111df52
parent68fe5182c967259ef89dbe313e4bf80f45a53e7e
parent211365d68c8eb5515cb658c4c240c73c122d2c5e
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 `()`
```
src/librustc_typeck/check/mod.rs