Skip to content

Commit 97ad7e6

Browse files
committed
chore: fix cargo clippy
1 parent 5f0ba94 commit 97ad7e6

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

opentelemetry/src/context.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,11 @@ impl Drop for ContextGuard {
484484
if id > ContextStack::BASE_POS && id < ContextStack::MAX_POS {
485485
// Extract only the span to drop outside of borrow_mut to avoid panic
486486
// when the span's drop implementation calls Context::current()
487+
#[cfg(feature = "trace")]
487488
let _to_drop =
488489
CURRENT_CONTEXT.with(|context_stack| context_stack.borrow_mut().pop_id(id));
490+
#[cfg(not(feature = "trace"))]
491+
CURRENT_CONTEXT.with(|context_stack| context_stack.borrow_mut().pop_id(id));
489492
// Span (if any) is automatically dropped here, outside of borrow_mut scope
490493
}
491494
}
@@ -587,8 +590,6 @@ impl ContextStack {
587590
);
588591
#[cfg(feature = "trace")]
589592
return None;
590-
#[cfg(not(feature = "trace"))]
591-
return;
592593
}
593594
let len: u16 = self.stack.len() as u16;
594595
// Are we at the top of the [`ContextStack`]?
@@ -601,18 +602,19 @@ impl ContextStack {
601602
// empty context is always at the bottom of the stack if the
602603
// [`ContextStack`] is not empty.
603604
if let Some(Some(next_cx)) = self.stack.pop() {
604-
let old_cx = std::mem::replace(&mut self.current_cx, next_cx);
605605
// Extract and return only the span to avoid cloning the entire Context
606606
#[cfg(feature = "trace")]
607-
return old_cx.span;
608-
#[cfg(not(feature = "trace"))]
609-
return;
610-
} else {
611-
#[cfg(feature = "trace")]
612-
return None;
607+
{
608+
let old_cx = std::mem::replace(&mut self.current_cx, next_cx);
609+
return old_cx.span;
610+
}
613611
#[cfg(not(feature = "trace"))]
614-
return;
612+
{
613+
self.current_cx = next_cx;
614+
}
615615
}
616+
#[cfg(feature = "trace")]
617+
return None;
616618
} else {
617619
// This is an out of order pop.
618620
if pos >= len {
@@ -625,16 +627,13 @@ impl ContextStack {
625627
);
626628
#[cfg(feature = "trace")]
627629
return None;
628-
#[cfg(not(feature = "trace"))]
629-
return;
630630
}
631631
// Clear out the entry at the given id and extract its span
632632
#[cfg(feature = "trace")]
633633
return self.stack[pos as usize].take().and_then(|cx| cx.span);
634634
#[cfg(not(feature = "trace"))]
635635
{
636636
self.stack[pos as usize] = None;
637-
return;
638637
}
639638
}
640639
}

0 commit comments

Comments
 (0)