tikv / pprof-rs

A Rust CPU profiler implemented with the help of backtrace-rs
Apache License 2.0
1.32k stars 105 forks source link

cannot compile this crate #66

Closed petar-dambovaliev closed 3 years ago

petar-dambovaliev commented 3 years ago

If it can't compile without the flamegraph feature, why is it optional?

pub enum Output<'a> {
    #[cfg(feature = "flamegraph")]
    Flamegraph(Option<FlamegraphOptions<'a>>),

    #[cfg(feature = "protobuf")]
    Protobuf,
}
 |
17 | pub enum Output<'a> {
   |                 ^^ unused parameter
   |
YangKeao commented 3 years ago

Oh, sorry! It seems that this problem only occurs when criterion feature is enabled without flamegraph. I will try to fix it right now! The problem locates at:

pub enum Output<'a> {
    #[cfg(feature = "flamegraph")]
    Flamegraph(Option<FlamegraphOptions<'a>>),

    #[cfg(feature = "protobuf")]
    Protobuf,
}

When flamegraph is not enabled, the 'a is an unused parameter. I don't know what's the best practice to fix this problem :man_facepalming: . Adding a PhantomData option for this enum is a little wired (or needs exhaustive_patterns).

Maybe writing different enum definitions for different conditions is the best choice, though ugly.