forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#81407 - osa1:issue81098, r=estebank
Refine "remove semicolon" suggestion in trait selection Don't suggest it if the last statement doesn't have a semicolon Fixes rust-lang#81098 See also rust-lang#54771 for why this suggestion was added
- Loading branch information
Showing
3 changed files
with
40 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
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,13 @@ | ||
// Don't suggest removing a semicolon if the last statement isn't an expression with semicolon | ||
// (#81098) | ||
fn wat() -> impl core::fmt::Display { //~ ERROR: `()` doesn't implement `std::fmt::Display` | ||
fn why() {} | ||
} | ||
|
||
// Do it if the last statement is an expression with semicolon | ||
// (#54771) | ||
fn ok() -> impl core::fmt::Display { //~ ERROR: `()` doesn't implement `std::fmt::Display` | ||
1; | ||
} | ||
|
||
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,23 @@ | ||
error[E0277]: `()` doesn't implement `std::fmt::Display` | ||
--> $DIR/issue-81098.rs:3:13 | ||
| | ||
LL | fn wat() -> impl core::fmt::Display { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter | ||
| | ||
= help: the trait `std::fmt::Display` is not implemented for `()` | ||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead | ||
|
||
error[E0277]: `()` doesn't implement `std::fmt::Display` | ||
--> $DIR/issue-81098.rs:9:12 | ||
| | ||
LL | fn ok() -> impl core::fmt::Display { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter | ||
LL | 1; | ||
| - consider removing this semicolon | ||
| | ||
= help: the trait `std::fmt::Display` is not implemented for `()` | ||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |