aclysma/profiling

Unused Variable Errors When No Backend Selected

cwfitzgerald opened this issue · 2 comments

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?

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.

Point taken