Skip to content

Commit 2790681

Browse files
committed
Add compile error on const fn instrumentation
1 parent 02903cb commit 2790681

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tracing-attributes/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ fn instrument_precise(
385385
let input = syn::parse::<ItemFn>(item)?;
386386
let instrumented_function_name = input.sig.ident.to_string();
387387

388+
macro_rules! error_on_const_fn {
389+
($e:expr) => {
390+
if $e {
391+
compile_error!("instrumenting const fn not supported");
392+
}
393+
};
394+
}
395+
error_on_const_fn!(input.sig.constness.is_some());
396+
388397
// check for async_trait-like patterns in the block, and instrument
389398
// the future instead of the wrapper
390399
if let Some(async_like) = expand::AsyncInfo::from_fn(&input) {

0 commit comments

Comments
 (0)