-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This amends off of an existing test introduced in #81769, if you think I should make a separate test I will.
- Loading branch information
1 parent
eddf806
commit ab7c446
Showing
2 changed files
with
42 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
// > Suggest `return`ing tail expressions that match return type | ||
// > | ||
// > Some newcomers are confused by the behavior of tail expressions, | ||
// > interpreting that "leaving out the `;` makes it the return value". | ||
// > To help them go in the right direction, suggest using `return` instead | ||
// > when applicable. | ||
// (original commit description for this test) | ||
// | ||
// This test was amended to also serve as a regression test for #92308, where | ||
// this suggestion would not trigger with async functions. | ||
// | ||
// edition:2018 | ||
|
||
fn main() { | ||
let _ = foo(true); | ||
} | ||
|
||
fn foo(x: bool) -> Result<f64, i32> { | ||
if x { | ||
Err(42) //~ ERROR mismatched types | ||
//| HELP you might have meant to return this value | ||
} | ||
Ok(42.0) | ||
} | ||
|
||
async fn bar(x: bool) -> Result<f64, i32> { | ||
if x { | ||
Err(42) //~ ERROR mismatched types | ||
//| HELP you might have meant to return this value | ||
} | ||
Ok(42.0) | ||
} |
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