async doesn't seem to work?
kurtbuilds opened this issue · comments
Kurt Wolf commented
This snippit:
fn codegen() -> TokenStream {
quote! {
use tokio;
pub async fn main() {
println!("Hello, world!");
}
}
}
fails with
error: can't qualify macro invocation with `pub`
--> stdin:1:13
|
1 | use tokio ; pub async fn main () { println ! ("Hello, world!") ; }
| ^^^
|
= help: try adjusting the macro to put `pub` inside the invocation
error: expected one of `!` or `::`, found `fn`
--> stdin:1:23
|
1 | use tokio ; pub async fn main () { println ! ("Hello, world!") ; }
| -^^ unexpected token
| |
| expected one of `!` or `::` here
Are async functions not supported? Are there recommended workarounds?
Kurt Wolf commented
This code
fn codegen() -> TokenStream {
quote! {
use tokio;
pub fn main() -> impl Future<Output = Result<(), anyhow::Error>> {
async {
println!("Hello, world!");
Ok(())
}
}
}
}
also fails, with a different error:
error: expected one of `,` or `}`, found `!`
--> stdin:1:105
|
1 | use tokio ; pub fn main () -> impl Future < Output = Result < () , anyhow :: Error >> { async { println ! ("Hello, world!") ; Ok (()) } }
| -^ unexpected token
| |
| expected one of `,` or `}` here