about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-05 22:25:47 +0000
committerbors <bors@rust-lang.org>2019-01-05 22:25:47 +0000
commitad9068f874007e732d59ffef141f3ccd43e43a6b (patch)
treed5406cd031b26855632d8bb9ff37fc021111df52 /src/test/ui
parent68fe5182c967259ef89dbe313e4bf80f45a53e7e (diff)
parent211365d68c8eb5515cb658c4c240c73c122d2c5e (diff)
downloadrust-ad9068f874007e732d59ffef141f3ccd43e43a6b.tar.gz
rust-ad9068f874007e732d59ffef141f3ccd43e43a6b.zip
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')
-rw-r--r--src/test/ui/block-result/consider-removing-last-semi.stderr32
-rw-r--r--src/test/ui/block-result/issue-11714.stderr17
-rw-r--r--src/test/ui/block-result/issue-13428.stderr35
-rw-r--r--src/test/ui/coercion/coercion-missing-tail-expected-type.stderr28
-rw-r--r--src/test/ui/issues/issue-32323.stderr6
-rw-r--r--src/test/ui/issues/issue-43162.stderr16
-rw-r--r--src/test/ui/issues/issue-44023.stderr10
-rw-r--r--src/test/ui/issues/issue-6458-4.stderr14
-rw-r--r--src/test/ui/liveness/liveness-forgot-ret.stderr6
-rw-r--r--src/test/ui/liveness/liveness-missing-ret2.stderr13
-rw-r--r--src/test/ui/liveness/liveness-return-last-stmt-semi.stderr41
-rw-r--r--src/test/ui/missing/missing-return.stderr6
12 files changed, 112 insertions, 112 deletions
diff --git a/src/test/ui/block-result/consider-removing-last-semi.stderr b/src/test/ui/block-result/consider-removing-last-semi.stderr
index 870da00680f..1bf17db21ac 100644
--- a/src/test/ui/block-result/consider-removing-last-semi.stderr
+++ b/src/test/ui/block-result/consider-removing-last-semi.stderr
@@ -1,27 +1,27 @@
 error[E0308]: mismatched types
-  --> $DIR/consider-removing-last-semi.rs:1:18
+  --> $DIR/consider-removing-last-semi.rs:1:11
    |
-LL |   fn f() -> String {  //~ ERROR mismatched types
-   |  __________________^
-LL | |     0u8;
-LL | |     "bla".to_string();
-   | |                      - help: consider removing this semicolon
-LL | | }
-   | |_^ expected struct `std::string::String`, found ()
+LL | fn f() -> String {  //~ ERROR mismatched types
+   |    -      ^^^^^^ expected struct `std::string::String`, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     0u8;
+LL |     "bla".to_string();
+   |                      - help: consider removing this semicolon
    |
    = note: expected type `std::string::String`
               found type `()`
 
 error[E0308]: mismatched types
-  --> $DIR/consider-removing-last-semi.rs:6:18
+  --> $DIR/consider-removing-last-semi.rs:6:11
    |
-LL |   fn g() -> String {  //~ ERROR mismatched types
-   |  __________________^
-LL | |     "this won't work".to_string();
-LL | |     "removeme".to_string();
-   | |                           - help: consider removing this semicolon
-LL | | }
-   | |_^ expected struct `std::string::String`, found ()
+LL | fn g() -> String {  //~ ERROR mismatched types
+   |    -      ^^^^^^ expected struct `std::string::String`, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     "this won't work".to_string();
+LL |     "removeme".to_string();
+   |                           - help: consider removing this semicolon
    |
    = note: expected type `std::string::String`
               found type `()`
diff --git a/src/test/ui/block-result/issue-11714.stderr b/src/test/ui/block-result/issue-11714.stderr
index 8bb37395c5c..2c13b287669 100644
--- a/src/test/ui/block-result/issue-11714.stderr
+++ b/src/test/ui/block-result/issue-11714.stderr
@@ -1,14 +1,13 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-11714.rs:1:18
+  --> $DIR/issue-11714.rs:1:14
    |
-LL |   fn blah() -> i32 { //~ ERROR mismatched types
-   |  __________________^
-LL | |     1
-LL | |
-LL | |     ;
-   | |     - help: consider removing this semicolon
-LL | | }
-   | |_^ expected i32, found ()
+LL | fn blah() -> i32 { //~ ERROR mismatched types
+   |    ----      ^^^ expected i32, found ()
+   |    |
+   |    this function's body doesn't return
+...
+LL |     ;
+   |     - help: consider removing this semicolon
    |
    = note: expected type `i32`
               found type `()`
diff --git a/src/test/ui/block-result/issue-13428.stderr b/src/test/ui/block-result/issue-13428.stderr
index 516baa8e5f1..91e926eb5a7 100644
--- a/src/test/ui/block-result/issue-13428.stderr
+++ b/src/test/ui/block-result/issue-13428.stderr
@@ -1,30 +1,27 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-13428.rs:3:20
+  --> $DIR/issue-13428.rs:3:13
    |
-LL |   fn foo() -> String {  //~ ERROR mismatched types
-   |  ____________________^
-LL | |     format!("Hello {}",
-LL | |             "world")
-LL | |     // Put the trailing semicolon on its own line to test that the
-LL | |     // note message gets the offending semicolon exactly
-LL | |     ;
-   | |     - help: consider removing this semicolon
-LL | | }
-   | |_^ expected struct `std::string::String`, found ()
+LL | fn foo() -> String {  //~ ERROR mismatched types
+   |    ---      ^^^^^^ expected struct `std::string::String`, found ()
+   |    |
+   |    this function's body doesn't return
+...
+LL |     ;
+   |     - help: consider removing this semicolon
    |
    = note: expected type `std::string::String`
               found type `()`
 
 error[E0308]: mismatched types
-  --> $DIR/issue-13428.rs:11:20
+  --> $DIR/issue-13428.rs:11:13
    |
-LL |   fn bar() -> String {  //~ ERROR mismatched types
-   |  ____________________^
-LL | |     "foobar".to_string()
-LL | |     ;
-   | |     - help: consider removing this semicolon
-LL | | }
-   | |_^ expected struct `std::string::String`, found ()
+LL | fn bar() -> String {  //~ ERROR mismatched types
+   |    ---      ^^^^^^ expected struct `std::string::String`, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     "foobar".to_string()
+LL |     ;
+   |     - help: consider removing this semicolon
    |
    = note: expected type `std::string::String`
               found type `()`
diff --git a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr
index 18adf9a46cc..c8ec2f0545e 100644
--- a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr
+++ b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr
@@ -1,25 +1,25 @@
 error[E0308]: mismatched types
-  --> $DIR/coercion-missing-tail-expected-type.rs:3:28
+  --> $DIR/coercion-missing-tail-expected-type.rs:3:24
    |
-LL |   fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
-   |  ____________________________^
-LL | |     x + 1;
-   | |          - help: consider removing this semicolon
-LL | | }
-   | |_^ expected i32, found ()
+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 `()`
 
 error[E0308]: mismatched types
-  --> $DIR/coercion-missing-tail-expected-type.rs:7:29
+  --> $DIR/coercion-missing-tail-expected-type.rs:7:13
    |
-LL |   fn foo() -> Result<u8, u64> { //~ ERROR mismatched types
-   |  _____________________________^
-LL | |     Ok(1);
-   | |          - help: consider removing this semicolon
-LL | | }
-   | |_^ expected enum `std::result::Result`, found ()
+LL | fn foo() -> Result<u8, u64> { //~ ERROR mismatched types
+   |    ---      ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     Ok(1);
+   |          - help: consider removing this semicolon
    |
    = note: expected type `std::result::Result<u8, u64>`
               found type `()`
diff --git a/src/test/ui/issues/issue-32323.stderr b/src/test/ui/issues/issue-32323.stderr
index 00ef2ca1809..0339fdc55b9 100644
--- a/src/test/ui/issues/issue-32323.stderr
+++ b/src/test/ui/issues/issue-32323.stderr
@@ -1,8 +1,10 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-32323.rs:5:49
+  --> $DIR/issue-32323.rs:5:30
    |
 LL | pub fn f<'a, T: Tr<'a>>() -> <T as Tr<'a>>::Out {}
-   |                                                 ^^ expected associated type, found ()
+   |        -                     ^^^^^^^^^^^^^^^^^^ expected associated type, found ()
+   |        |
+   |        this function's body doesn't return
    |
    = note: expected type `<T as Tr<'a>>::Out`
               found type `()`
diff --git a/src/test/ui/issues/issue-43162.stderr b/src/test/ui/issues/issue-43162.stderr
index 8b02476841d..3fc5317830e 100644
--- a/src/test/ui/issues/issue-43162.stderr
+++ b/src/test/ui/issues/issue-43162.stderr
@@ -11,15 +11,15 @@ LL |     break {}; //~ ERROR E0268
    |     ^^^^^^^^ cannot break outside of a loop
 
 error[E0308]: mismatched types
-  --> $DIR/issue-43162.rs:1:18
+  --> $DIR/issue-43162.rs:1:13
    |
-LL |   fn foo() -> bool {
-   |  __________________^
-LL | |     //~^ ERROR E0308
-LL | |     break true; //~ ERROR E0268
-   | |               - help: consider removing this semicolon
-LL | | }
-   | |_^ expected bool, found ()
+LL | fn foo() -> bool {
+   |    ---      ^^^^ expected bool, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     //~^ ERROR E0308
+LL |     break true; //~ ERROR E0268
+   |               - help: consider removing this semicolon
    |
    = note: expected type `bool`
               found type `()`
diff --git a/src/test/ui/issues/issue-44023.stderr b/src/test/ui/issues/issue-44023.stderr
index 21cfe07e3e6..f1962a86ee0 100644
--- a/src/test/ui/issues/issue-44023.stderr
+++ b/src/test/ui/issues/issue-44023.stderr
@@ -1,10 +1,10 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-44023.rs:5:42
+  --> $DIR/issue-44023.rs:5:36
    |
-LL |   fn საჭმელად_გემრიელი_სადილი ( ) -> isize { //~ ERROR mismatched types
-   |  __________________________________________^
-LL | | }
-   | |_^ expected isize, found ()
+LL | fn საჭმელად_გემრიელი_სადილი ( ) -> 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/issues/issue-6458-4.stderr b/src/test/ui/issues/issue-6458-4.stderr
index 3e621c17cdc..c087292e978 100644
--- a/src/test/ui/issues/issue-6458-4.stderr
+++ b/src/test/ui/issues/issue-6458-4.stderr
@@ -1,12 +1,12 @@
 error[E0308]: mismatched types
-  --> $DIR/issue-6458-4.rs:1:40
+  --> $DIR/issue-6458-4.rs:1:20
    |
-LL |   fn foo(b: bool) -> Result<bool,String> { //~ ERROR mismatched types
-   |  ________________________________________^
-LL | |     Err("bar".to_string());
-   | |                           - help: consider removing this semicolon
-LL | | }
-   | |_^ expected enum `std::result::Result`, found ()
+LL | fn foo(b: bool) -> Result<bool,String> { //~ ERROR mismatched types
+   |    ---             ^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
+   |    |
+   |    this function's body doesn't return
+LL |     Err("bar".to_string());
+   |                           - help: consider removing this semicolon
    |
    = note: expected type `std::result::Result<bool, std::string::String>`
               found type `()`
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 `()`
diff --git a/src/test/ui/missing/missing-return.stderr b/src/test/ui/missing/missing-return.stderr
index 6d42dafd6f1..42466e2fc65 100644
--- a/src/test/ui/missing/missing-return.stderr
+++ b/src/test/ui/missing/missing-return.stderr
@@ -1,8 +1,10 @@
 error[E0308]: mismatched types
-  --> $DIR/missing-return.rs:3:17
+  --> $DIR/missing-return.rs:3:11
    |
 LL | fn f() -> isize { }
-   |                 ^^^ expected isize, found ()
+   |    -      ^^^^^ expected isize, found ()
+   |    |
+   |    this function's body doesn't return
    |
    = note: expected type `isize`
               found type `()`