Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in type resolution in #[tokio::main] macro #4175

Closed
KamilaBorowska opened this issue Oct 18, 2021 · 1 comment · Fixed by #4176
Closed

Regression in type resolution in #[tokio::main] macro #4175

KamilaBorowska opened this issue Oct 18, 2021 · 1 comment · Fixed by #4176
Assignees
Labels
A-tokio-macros Area: The tokio-macros crate C-bug Category: This is a bug.

Comments

@KamilaBorowska
Copy link
Contributor

Version
List the versions of all tokio crates you are using. The easiest way to get
this information is using cargo tree subcommand:

cargo tree | grep tokio

└── tokio v1.12.0
    └── tokio-macros v1.5.0 (proc-macro)

Platform
The output of uname -a (UNIX), or version and 32 or 64-bit (Windows)

Linux nixos 5.10.71 #1-NixOS SMP Wed Oct 6 13:56:04 UTC 2021 x86_64 GNU/Linux

Description
Enter your issue details here.
One way to structure the description:

Ending async fn main() -> ! (where ! is any termination type other than ()) function with panic!(); causes compilation failure.

I tried this code:

#[tokio::main]
async fn main() -> ! {
    panic!();
}

I expected to see this happen: Compilation to succeed

Instead, this happened:

error[E0308]: mismatched types
 --> src/main.rs:2:20
  |
1 | #[tokio::main]
  |              - help: consider removing this semicolon
2 | async fn main() -> ! {
  |          ----      ^ expected `!`, found `()`
  |          |
  |          implicitly returns `()` as its body has no tail or `return` expression
  |
  = note:   expected type `!`
          found unit type `()`

This is a regression in tokio-macros 1.4.1, this code did work fine with tokio-macros 1.3.0. It affected tests in my code, see https://gitlab.com/KonradBorowski/showdown/-/blob/413fac7fdcd1b22ad9a6fbf495a79ae5d8e1473c/src/lib.rs#L187 for an example of affected test.

@KamilaBorowska KamilaBorowska added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Oct 18, 2021
@taiki-e taiki-e added A-tokio-macros Area: The tokio-macros crate and removed A-tokio Area: The main tokio crate labels Oct 18, 2021
@taiki-e taiki-e self-assigned this Oct 18, 2021
@KamilaBorowska KamilaBorowska changed the title Regression in type resolution of #[tokio::main] macro Regression in type resolution in #[tokio::main] macro Oct 18, 2021
@taiki-e
Copy link
Member

taiki-e commented Oct 18, 2021

This will be fixed in #4176.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-macros Area: The tokio-macros crate C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants