6

Github futures-macro: improve diagnostics on type mismatch by taiki-e · Pull Req...

 3 years ago
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.
neoserver,ios ssh client

Copy link

Member

taiki-e commented 24 days ago

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<(), _> {
  |              ^^^^^^^^^^^^^^^^

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK