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.
only suggest removing semicolon when expr implements trait
- Loading branch information
1 parent
027a232
commit dfe13db
Showing
15 changed files
with
97 additions
and
32 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
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
21 changes: 19 additions & 2 deletions
21
src/test/ui/suggestions/impl-trait-return-trailing-semicolon.rs
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,8 +1,25 @@ | ||
trait Bar {} | ||
impl Bar for u8 {} | ||
|
||
impl Bar for i32 {} | ||
|
||
struct Qux; | ||
|
||
impl Bar for Qux {} | ||
|
||
fn foo() -> impl Bar { | ||
5; //~^ ERROR the trait bound `(): Bar` is not satisfied | ||
//~^ ERROR the trait bound `(): Bar` is not satisfied | ||
//~| ERROR the trait bound `(): Bar` is not satisfied | ||
//~| HELP the following other types implement trait `Bar`: | ||
5; | ||
//~^ HELP remove this semicolon | ||
} | ||
|
||
fn bar() -> impl Bar { | ||
//~^ ERROR the trait bound `(): Bar` is not satisfied | ||
//~| ERROR the trait bound `(): Bar` is not satisfied | ||
//~| HELP the following other types implement trait `Bar`: | ||
//~| HELP the following other types implement trait `Bar`: | ||
""; | ||
} | ||
|
||
fn main() {} |
45 changes: 40 additions & 5 deletions
45
src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr
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,23 +1,58 @@ | ||
error[E0277]: the trait bound `(): Bar` is not satisfied | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:3:13 | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:9:13 | ||
| | ||
LL | fn foo() -> impl Bar { | ||
| ^^^^^^^^ the trait `Bar` is not implemented for `()` | ||
... | ||
LL | 5; | ||
| - consider removing this semicolon | ||
| -- help: remove this semicolon | ||
| | | ||
| this expression has type `{integer}`, which implements `Bar` | ||
|
||
error[E0277]: the trait bound `(): Bar` is not satisfied | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:3:22 | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:9:22 | ||
| | ||
LL | fn foo() -> impl Bar { | ||
| ______________________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | 5; | ||
LL | | | ||
LL | | } | ||
| |_^ the trait `Bar` is not implemented for `()` | ||
| | ||
= help: the trait `Bar` is implemented for `u8` | ||
= help: the following other types implement trait `Bar`: | ||
Qux | ||
i32 | ||
|
||
error[E0277]: the trait bound `(): Bar` is not satisfied | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:17:13 | ||
| | ||
LL | fn bar() -> impl Bar { | ||
| ^^^^^^^^ the trait `Bar` is not implemented for `()` | ||
| | ||
= help: the following other types implement trait `Bar`: | ||
Qux | ||
i32 | ||
|
||
error[E0277]: the trait bound `(): Bar` is not satisfied | ||
--> $DIR/impl-trait-return-trailing-semicolon.rs:17:22 | ||
| | ||
LL | fn bar() -> impl Bar { | ||
| ______________________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | ""; | ||
LL | | } | ||
| |_^ the trait `Bar` is not implemented for `()` | ||
| | ||
= help: the following other types implement trait `Bar`: | ||
Qux | ||
i32 | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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