review comment: review wording or missing return error

This commit is contained in:
Esteban Küber 2019-08-08 15:55:18 -07:00
parent 5a54945b6f
commit 33d1082d6e
15 changed files with 22 additions and 21 deletions

View file

@ -3711,7 +3711,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(fn_span) = fn_span {
err.span_label(
fn_span,
"this function's body doesn't `return` a value",
"this function implicitly returns `()` as its body has no tail \
or `return` expression",
);
}
}, false);

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn f() -> String {
| - ^^^^^^ expected struct `std::string::String`, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | 0u8;
LL | "bla".to_string();
| - help: consider removing this semicolon
@ -18,7 +18,7 @@ error[E0308]: mismatched types
LL | fn g() -> String {
| - ^^^^^^ expected struct `std::string::String`, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | "this won't work".to_string();
LL | "removeme".to_string();
| - help: consider removing this semicolon

View file

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

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn foo() -> String {
| --- ^^^^^^ expected struct `std::string::String`, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
...
LL | ;
| - help: consider removing this semicolon
@ -18,7 +18,7 @@ error[E0308]: mismatched types
LL | fn bar() -> String {
| --- ^^^^^^ expected struct `std::string::String`, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | "foobar".to_string()
LL | ;
| - help: consider removing this semicolon

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn plus_one(x: i32) -> i32 {
| -------- ^^^ expected i32, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | x + 1;
| - help: consider removing this semicolon
|
@ -17,7 +17,7 @@ error[E0308]: mismatched types
LL | fn foo() -> Result<u8, u64> {
| --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | Ok(1);
| - help: consider removing this semicolon
|

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
| --- ^^^ - help: consider removing this semicolon
| | |
| | expected i32, found ()
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
...
LL | test!();
| -------- in this macro invocation
@ -19,7 +19,7 @@ error[E0308]: mismatched types
LL | fn no_return() -> i32 {}
| --------- ^^^ expected i32, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected type `i32`
found type `()`
@ -30,7 +30,7 @@ error[E0308]: mismatched types
LL | fn bar(x: u32) -> u32 {
| --- ^^^ expected u32, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
LL | x * 2;
| - help: consider removing this semicolon
|
@ -43,7 +43,7 @@ error[E0308]: mismatched types
LL | fn baz(x: u64) -> u32 {
| --- ^^^ expected u32, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected type `u32`
found type `()`

View file

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

View file

@ -19,7 +19,7 @@ error[E0308]: mismatched types
LL | fn f() -> isize { fn f() -> isize {} pub f<
| - ^^^^^ expected isize, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected type `isize`
found type `()`

View file

@ -38,7 +38,7 @@ error[E0308]: mismatched types
LL | fn v() -> isize {
| - ^^^^^ expected isize, found ()
| |
| this function's body doesn't `return` a value
| this function implicitly returns `()` as its body has no tail or `return` expression
|
= note: expected type `isize`
found type `()`