aclysma / profiling

Provides a very thin abstraction over instrumented profiling crates like puffin, optick, tracy, and superluminal-perf.
Apache License 2.0
319 stars 39 forks source link

Unused Variable Errors When No Backend Selected #28

Closed cwfitzgerald closed 2 years ago

cwfitzgerald commented 2 years ago

Take the following code:

let label = format!("Some {} string {}", "complicated", "substitution");
profiling::scope!(&label);

If no profiling backend was selected, label will be marked as unused.

If the no-op scope macro was say:

macro_rules! scope {
    ($name:expr) => {{ let _ = $name; }};
    ($name:expr, $data:expr) => {{ let _ = $name; let _ = $expr; }};
}

This would eliminate these unused variable warnings.

Thoughts?

aclysma commented 2 years ago

I think getting a warning is desirable in this case, calling format!() isn't cheap and most users would probably want to know about this so they can remove it. I would suggest putting the format!() in the scope!() call.

cwfitzgerald commented 2 years ago

Point taken