Skip to content

Commit 0e4a4be

Browse files
authored
attributes: change order of async and unsafe modifier (tokio-rs#2864)
When using `#[tracing::instrument]` and the `async unsafe` modifiers the generated function read `unsafe async fn`, which is wrong. Corrected the order and added a test. Fixes: tokio-rs#2576 Signed-off-by: Gabriel Goller <[email protected]>
1 parent c6bedbe commit 0e4a4be

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tracing-attributes/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub(crate) fn gen_function<'a, B: ToTokens + 'a>(
9292

9393
quote!(
9494
#(#outer_attrs) *
95-
#vis #constness #unsafety #asyncness #abi fn #ident<#gen_params>(#params) #output
95+
#vis #constness #asyncness #unsafety #abi fn #ident<#gen_params>(#params) #output
9696
#where_clause
9797
{
9898
#(#inner_attrs) *

tracing-attributes/tests/async_fn.rs

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ async fn test_ret_impl_trait_err(n: i32) -> Result<impl Iterator<Item = i32>, &'
3131
#[instrument]
3232
async fn test_async_fn_empty() {}
3333

34+
#[instrument]
35+
async unsafe fn test_async_unsafe_fn_empty() {}
36+
3437
// Reproduces a compile error when an instrumented function body contains inner
3538
// attributes (https://github.com/tokio-rs/tracing/issues/2294).
3639
#[deny(unused_variables)]

0 commit comments

Comments
 (0)