Skip to content

Commit 8756311

Browse files
committed
review comment: review wording or missing return error
1 parent d1dcd1d commit 8756311

15 files changed

+22
-21
lines changed

src/librustc_typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3711,7 +3711,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37113711
if let Some(fn_span) = fn_span {
37123712
err.span_label(
37133713
fn_span,
3714-
"this function's body doesn't `return` a value",
3714+
"this function implicitly returns `()` as its body has no tail \
3715+
or `return` expression",
37153716
);
37163717
}
37173718
}, false);

src/test/ui/block-result/consider-removing-last-semi.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn f() -> String {
55
| - ^^^^^^ expected struct `std::string::String`, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
LL | 0u8;
99
LL | "bla".to_string();
1010
| - help: consider removing this semicolon
@@ -18,7 +18,7 @@ error[E0308]: mismatched types
1818
LL | fn g() -> String {
1919
| - ^^^^^^ expected struct `std::string::String`, found ()
2020
| |
21-
| this function's body doesn't `return` a value
21+
| this function implicitly returns `()` as its body has no tail or `return` expression
2222
LL | "this won't work".to_string();
2323
LL | "removeme".to_string();
2424
| - help: consider removing this semicolon

src/test/ui/block-result/issue-11714.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn blah() -> i32 {
55
| ---- ^^^ expected i32, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
...
99
LL | ;
1010
| - help: consider removing this semicolon

src/test/ui/block-result/issue-13428.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn foo() -> String {
55
| --- ^^^^^^ expected struct `std::string::String`, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
...
99
LL | ;
1010
| - help: consider removing this semicolon
@@ -18,7 +18,7 @@ error[E0308]: mismatched types
1818
LL | fn bar() -> String {
1919
| --- ^^^^^^ expected struct `std::string::String`, found ()
2020
| |
21-
| this function's body doesn't `return` a value
21+
| this function implicitly returns `()` as its body has no tail or `return` expression
2222
LL | "foobar".to_string()
2323
LL | ;
2424
| - help: consider removing this semicolon

src/test/ui/coercion/coercion-missing-tail-expected-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn plus_one(x: i32) -> i32 {
55
| -------- ^^^ expected i32, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
LL | x + 1;
99
| - help: consider removing this semicolon
1010
|
@@ -17,7 +17,7 @@ error[E0308]: mismatched types
1717
LL | fn foo() -> Result<u8, u64> {
1818
| --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
1919
| |
20-
| this function's body doesn't `return` a value
20+
| this function implicitly returns `()` as its body has no tail or `return` expression
2121
LL | Ok(1);
2222
| - help: consider removing this semicolon
2323
|

src/test/ui/issues/issue-32323.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | pub fn f<'a, T: Tr<'a>>() -> <T as Tr<'a>>::Out {}
55
| - ^^^^^^^^^^^^^^^^^^ expected associated type, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
|
99
= note: expected type `<T as Tr<'a>>::Out`
1010
found type `()`

src/test/ui/issues/issue-43162.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
1616
LL | fn foo() -> bool {
1717
| --- ^^^^ expected bool, found ()
1818
| |
19-
| this function's body doesn't `return` a value
19+
| this function implicitly returns `()` as its body has no tail or `return` expression
2020
LL |
2121
LL | break true;
2222
| - help: consider removing this semicolon

src/test/ui/issues/issue-44023.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn საჭმელად_გემრიელი_სადილი ( ) -> isize {
55
| ------------------------ ^^^^^ expected isize, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
|
99
= note: expected type `isize`
1010
found type `()`

src/test/ui/issues/issue-6458-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn foo(b: bool) -> Result<bool,String> {
55
| --- ^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
LL | Err("bar".to_string());
99
| - help: consider removing this semicolon
1010
|

src/test/ui/liveness/liveness-forgot-ret.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn f(a: isize) -> isize { if god_exists(a) { return 5; }; }
55
| - ^^^^^ expected isize, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
|
99
= note: expected type `isize`
1010
found type `()`

src/test/ui/liveness/liveness-missing-ret2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn f() -> isize {
55
| - ^^^^^ expected isize, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
|
99
= note: expected type `isize`
1010
found type `()`

src/test/ui/liveness/liveness-return-last-stmt-semi.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
55
| --- ^^^ - help: consider removing this semicolon
66
| | |
77
| | expected i32, found ()
8-
| this function's body doesn't `return` a value
8+
| this function implicitly returns `()` as its body has no tail or `return` expression
99
...
1010
LL | test!();
1111
| -------- in this macro invocation
@@ -19,7 +19,7 @@ error[E0308]: mismatched types
1919
LL | fn no_return() -> i32 {}
2020
| --------- ^^^ expected i32, found ()
2121
| |
22-
| this function's body doesn't `return` a value
22+
| this function implicitly returns `()` as its body has no tail or `return` expression
2323
|
2424
= note: expected type `i32`
2525
found type `()`
@@ -30,7 +30,7 @@ error[E0308]: mismatched types
3030
LL | fn bar(x: u32) -> u32 {
3131
| --- ^^^ expected u32, found ()
3232
| |
33-
| this function's body doesn't `return` a value
33+
| this function implicitly returns `()` as its body has no tail or `return` expression
3434
LL | x * 2;
3535
| - help: consider removing this semicolon
3636
|
@@ -43,7 +43,7 @@ error[E0308]: mismatched types
4343
LL | fn baz(x: u64) -> u32 {
4444
| --- ^^^ expected u32, found ()
4545
| |
46-
| this function's body doesn't `return` a value
46+
| this function implicitly returns `()` as its body has no tail or `return` expression
4747
|
4848
= note: expected type `u32`
4949
found type `()`

src/test/ui/missing/missing-return.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
44
LL | fn f() -> isize { }
55
| - ^^^^^ expected isize, found ()
66
| |
7-
| this function's body doesn't `return` a value
7+
| this function implicitly returns `()` as its body has no tail or `return` expression
88
|
99
= note: expected type `isize`
1010
found type `()`

src/test/ui/parser/issue-62881.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ error[E0308]: mismatched types
1919
LL | fn f() -> isize { fn f() -> isize {} pub f<
2020
| - ^^^^^ expected isize, found ()
2121
| |
22-
| this function's body doesn't `return` a value
22+
| this function implicitly returns `()` as its body has no tail or `return` expression
2323
|
2424
= note: expected type `isize`
2525
found type `()`

src/test/ui/parser/issue-62895.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ error[E0308]: mismatched types
3838
LL | fn v() -> isize {
3939
| - ^^^^^ expected isize, found ()
4040
| |
41-
| this function's body doesn't `return` a value
41+
| this function implicitly returns `()` as its body has no tail or `return` expression
4242
|
4343
= note: expected type `isize`
4444
found type `()`

0 commit comments

Comments
 (0)