-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macros: improve diagnostics on type mismatch (#3766)
- Loading branch information
Showing
8 changed files
with
149 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![deny(dead_code)] | ||
|
||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
async fn f() {} | ||
|
||
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,11 @@ | ||
error: function is never used: `f` | ||
--> $DIR/macros_dead_code.rs:6:10 | ||
| | ||
6 | async fn f() {} | ||
| ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/macros_dead_code.rs:1:9 | ||
| | ||
1 | #![deny(dead_code)] | ||
| ^^^^^^^^^ |
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,32 @@ | ||
use tests_build::tokio; | ||
|
||
#[tokio::main] | ||
async fn missing_semicolon_or_return_type() { | ||
Ok(()) | ||
} | ||
|
||
#[tokio::main] | ||
async fn missing_return_type() { | ||
/* TODO(taiki-e): one of help messages still wrong | ||
help: consider using a semicolon here | ||
| | ||
16 | return Ok(());; | ||
| | ||
*/ | ||
return Ok(()); | ||
} | ||
|
||
#[tokio::main] | ||
async fn extra_semicolon() -> Result<(), ()> { | ||
/* TODO(taiki-e): help message still wrong | ||
help: try using a variant of the expected enum | ||
| | ||
29 | Ok(Ok(());) | ||
| | ||
29 | Err(Ok(());) | ||
| | ||
*/ | ||
Ok(()); | ||
} | ||
|
||
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,51 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/macros_type_mismatch.rs:5:5 | ||
| | ||
5 | Ok(()) | ||
| ^^^^^^ expected `()`, found enum `Result` | ||
| | ||
= note: expected unit type `()` | ||
found enum `Result<(), _>` | ||
help: consider using a semicolon here | ||
| | ||
5 | Ok(()); | ||
| ^ | ||
help: try adding a return type | ||
| | ||
4 | async fn missing_semicolon_or_return_type() -> Result<(), _> { | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/macros_type_mismatch.rs:16:5 | ||
| | ||
16 | return Ok(()); | ||
| ^^^^^^^^^^^^^^ expected `()`, found enum `Result` | ||
| | ||
= note: expected unit type `()` | ||
found enum `Result<(), _>` | ||
help: consider using a semicolon here | ||
| | ||
16 | return Ok(());; | ||
| ^ | ||
help: try adding a return type | ||
| | ||
9 | async fn missing_return_type() -> Result<(), _> { | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/macros_type_mismatch.rs:29:5 | ||
| | ||
20 | async fn extra_semicolon() -> Result<(), ()> { | ||
| -------------- expected `Result<(), ()>` because of return type | ||
... | ||
29 | Ok(()); | ||
| ^^^^^^^ expected enum `Result`, found `()` | ||
| | ||
= note: expected enum `Result<(), ()>` | ||
found unit type `()` | ||
help: try using a variant of the expected enum | ||
| | ||
29 | Ok(Ok(());) | ||
| | ||
29 | Err(Ok(());) | ||
| |
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
f9ce18a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'sync_mpsc'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
2
.send_large
59165
ns/iter (± 17621
)29481
ns/iter (± 1234
)2.01
This comment was automatically generated by workflow using github-action-benchmark.
CC: @tokio-rs/maintainers