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

#[tokio::main] ignores generics #2176

Closed
daxpedda opened this issue Jan 26, 2020 · 0 comments · Fixed by #2177
Closed

#[tokio::main] ignores generics #2176

daxpedda opened this issue Jan 26, 2020 · 0 comments · Fixed by #2177

Comments

@daxpedda
Copy link
Contributor

Version

tokio v0.2.10
tokio-macros v0.2.3
tokio-util v0.2.0

Subcrates

macros

Description

When using #[tokio::main] on a function with generics, the generics are skipped.

I tried this code:

#[tokio::main]
async fn generic_fun<T: Default>() -> T {
    T::default()
}

I expected to see this happen (on expansion):

fn generic_fun<T: Default>() -> T {
    tokio::runtime::Runtime::new().unwrap().block_on(async {
        {
            T::default()
        }
    })
}

Instead, this happened (on expansion):

fn generic_fun() -> T {
    tokio::runtime::Runtime::new().unwrap().block_on(async {
        {
            T::default()
        }
    })
}
carllerche pushed a commit that referenced this issue Jan 26, 2020
When using #[tokio::main] on a function with generics, the generics are
skipped. Simply using #vis #sig instead of #vis fn #name(#inputs) #ret
fixes the problem.

Fixes #2176
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant