-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest returning binding from block or enclosing scope on coerce_for…
…ced_unit error
- Loading branch information
1 parent
475aec1
commit b0a8190
Showing
10 changed files
with
314 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fn a(i: i32) -> i32 { | ||
//~^ ERROR mismatched types | ||
let j = 2i32; | ||
} | ||
|
||
fn b(i: i32, j: i32) -> i32 {} | ||
//~^ ERROR mismatched types | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/return-bindings-multi.rs:1:17 | ||
| | ||
LL | fn a(i: i32) -> i32 { | ||
| - ^^^ expected `i32`, found `()` | ||
| | | ||
| implicitly returns `()` as its body has no tail or `return` expression | ||
| | ||
note: consider returning one of these bindings | ||
--> $DIR/return-bindings-multi.rs:1:6 | ||
| | ||
LL | fn a(i: i32) -> i32 { | ||
| ^ | ||
LL | | ||
LL | let j = 2i32; | ||
| ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/return-bindings-multi.rs:6:25 | ||
| | ||
LL | fn b(i: i32, j: i32) -> i32 {} | ||
| - ^^^ expected `i32`, found `()` | ||
| | | ||
| implicitly returns `()` as its body has no tail or `return` expression | ||
| | ||
note: consider returning one of these bindings | ||
--> $DIR/return-bindings-multi.rs:6:6 | ||
| | ||
LL | fn b(i: i32, j: i32) -> i32 {} | ||
| ^ ^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn a(i: i32) -> i32 { i } | ||
//~^ ERROR mismatched types | ||
|
||
fn b(opt_str: Option<String>) { | ||
let s: String = if let Some(s) = opt_str { | ||
s | ||
//~^ ERROR mismatched types | ||
} else { | ||
String::new() | ||
}; | ||
} | ||
|
||
fn c() -> Option<i32> { | ||
//~^ ERROR mismatched types | ||
let x = Some(1); | ||
x | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
fn a(i: i32) -> i32 {} | ||
//~^ ERROR mismatched types | ||
|
||
fn b(opt_str: Option<String>) { | ||
let s: String = if let Some(s) = opt_str { | ||
//~^ ERROR mismatched types | ||
} else { | ||
String::new() | ||
}; | ||
} | ||
|
||
fn c() -> Option<i32> { | ||
//~^ ERROR mismatched types | ||
let x = Some(1); | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.