Skip to content

Commit

Permalink
macros: characterization tests for ? operator fail
Browse files Browse the repository at this point in the history
When a `?` operator is used in a tokio entry point function (wrapped in
`#[tokio::main]`), which has a Option or Result return type, but where
the function does not actually return that type correctly, currently the
compiler returns two errors instead of just one. The first of which is
incorrect and only exists due to the macro expanding to an async block.

```
cannot use the `?` operator in an async block that returns `()`
```

This commit is a characterization test for this behavior to help show
when it's fixed (or even changed for better / worse)
  • Loading branch information
joshka committed Jan 20, 2025
1 parent f92af23 commit 8cbf6b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests-build/tests/fail/macros_type_mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async fn extra_semicolon() -> Result<(), ()> {
Ok(());
}

/// This test is a charecterization test for the `?` operator.
/// This test is a characterization test for the `?` operator.
///
/// See <https://github.com/tokio-rs/tokio/issues/6930#issuecomment-2572502517> for more details.
///
Expand All @@ -40,7 +40,7 @@ async fn question_mark_operator_with_invalid_option() -> Option<()> {
None?;
}

/// This test is a charecterization test for the `?` operator.
/// This test is a characterization test for the `?` operator.
///
/// See <https://github.com/tokio-rs/tokio/issues/6930#issuecomment-2572502517> for more details.
///
Expand Down

0 comments on commit 8cbf6b2

Please sign in to comment.