Skip to content

Commit

Permalink
Fix compile warnings when trace feature is disabled (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax authored Jan 31, 2024
1 parent 2a0020f commit 45d4c2c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libcnb/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,14 @@ pub fn libcnb_runtime_detect<B: Buildpack>(
#[cfg(feature = "trace")]
let mut trace = start_trace(&buildpack_descriptor.buildpack, "detect");

#[cfg(feature = "trace")]
let mut trace_error = |err: &dyn std::error::Error| {
#[cfg(feature = "trace")]
trace.set_error(err);
};

#[cfg(not(feature = "trace"))]
let trace_error = |_: &dyn std::error::Error| {};

let stack_id: StackId = env::var("CNB_STACK_ID")
.map_err(Error::CannotDetermineStackId)
.and_then(|stack_id_string| stack_id_string.parse().map_err(Error::StackIdError))
Expand Down Expand Up @@ -190,6 +194,7 @@ pub fn libcnb_runtime_detect<B: Buildpack>(
///
/// Exposed only to allow for advanced use-cases where build is programmatically invoked.
#[doc(hidden)]
#[allow(clippy::too_many_lines)]
pub fn libcnb_runtime_build<B: Buildpack>(
buildpack: &B,
args: BuildArgs,
Expand All @@ -206,11 +211,14 @@ pub fn libcnb_runtime_build<B: Buildpack>(
#[cfg(feature = "trace")]
let mut trace = start_trace(&buildpack_descriptor.buildpack, "build");

#[cfg(feature = "trace")]
let mut trace_error = |err: &dyn std::error::Error| {
#[cfg(feature = "trace")]
trace.set_error(err);
};

#[cfg(not(feature = "trace"))]
let trace_error = |_: &dyn std::error::Error| {};

let stack_id: StackId = env::var("CNB_STACK_ID")
.map_err(Error::CannotDetermineStackId)
.and_then(|stack_id_string| stack_id_string.parse().map_err(Error::StackIdError))
Expand Down

0 comments on commit 45d4c2c

Please sign in to comment.