6
Github futures-macro: improve diagnostics on type mismatch by taiki-e · Pull Req...
source link: https://github.com/rust-lang/futures-rs/pull/2433
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Port of my patch (tokio-rs/tokio#3766) in tokio.
Code:
#[futures_test::test] async fn f() { Ok(()) }
Before:
error[E0308]: mismatched types
--> futures/tests/test_macro.rs:1:1
|
1 | #[futures_test::test]
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `Result`
|
= note: expected unit type `()`
found enum `Result<(), _>`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
After:
error[E0308]: mismatched types
--> futures/tests/test_macro.rs:3:5
|
3 | Ok(())
| ^^^^^^ expected `()`, found enum `Result`
|
= note: expected unit type `()`
found enum `Result<(), _>`
help: consider using a semicolon here
|
3 | Ok(());
| ^
help: try adding a return type
|
2 | async fn f() -> Result<(), _> {
| ^^^^^^^^^^^^^^^^
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK