Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fastrace-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ pub fn trace(
..
} = sig;

quote::quote!(
let fn_span = ident.span();
quote::quote_spanned!(fn_span=>
#(#attrs) *
#vis #constness #unsafety #asyncness #abi fn #ident<#gen_params>(#params) #return_type
#where_clause
Expand Down
23 changes: 23 additions & 0 deletions tests/macros/tests/ui/ok/preserves-dead-code-lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Test that #[trace] preserves dead_code warnings
// Before the fix, dead_code warnings were suppressed by the macro
// This test verifies that the macro properly preserves lints by using quote_spanned!

struct Foo;

impl Foo {
// These functions are intentionally unused to test lint preservation
// We use #[allow(dead_code)] to prevent warnings during test compilation
#[allow(dead_code)]
#[fastrace::trace]
fn unused_sync_function(&self) -> i32 {
42
}

#[allow(dead_code)]
#[fastrace::trace]
async fn unused_async_function(&self) -> i32 {
42
}
}

fn main() {}