Skip to content

Commit

Permalink
Add compile error on const fn instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpollack committed Dec 19, 2022
1 parent 02903cb commit 2790681
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tracing-attributes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,15 @@ fn instrument_precise(
let input = syn::parse::<ItemFn>(item)?;
let instrumented_function_name = input.sig.ident.to_string();

macro_rules! error_on_const_fn {
($e:expr) => {
if $e {
compile_error!("instrumenting const fn not supported");
}
};
}
error_on_const_fn!(input.sig.constness.is_some());

// check for async_trait-like patterns in the block, and instrument
// the future instead of the wrapper
if let Some(async_like) = expand::AsyncInfo::from_fn(&input) {
Expand Down

0 comments on commit 2790681

Please sign in to comment.