can't compile when async function block has variable not implement Send
#3066
Replies: 2 comments
-
fix compile the following code should not compile, but it can. #[derive(Debug)]
pub struct NotSend {
_not_send_sync: PhantomData<*const ()>,
}
pub async fn empty_func() {}
#[debug_handler]
pub async fn weird_func() -> impl IntoResponse {
empty_func().await;
let a = NotSend {
_not_send_sync: PhantomData,
};
println!(
"it will be compile when `async` function not use below {:?}",
a
);
()
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(weird_func));
let listener = tokio::net::TcpListener::bind("0.0.0.0:4000").await.unwrap();
axum::serve(listener, app).await.unwrap();
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
there may have some help |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
the
debug_handler
tell me this error message.that's weird i can even print it or do some operation but can't use
async
func after that variable.can anyone help me dig in why it happens. also my rust version is
1.83.0
.axum version
0.7.9
Beta Was this translation helpful? Give feedback.
All reactions