Skip to content

Commit 1561211

Browse files
committed
style: rename _guard to guard
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
1 parent 548250f commit 1561211

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

src/interrupt_dropper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ impl<T> DerefMut for InterruptDropper<T> {
4242
impl<T> Drop for InterruptDropper<T> {
4343
#[inline]
4444
fn drop(&mut self) {
45-
let _guard = interrupts::disable();
45+
let guard = interrupts::disable();
4646
// Drop `inner` as while we can guarentee interrupts are disabled
4747
// SAFETY: This is not exposed to safe code and is not called more than once
4848
unsafe { ManuallyDrop::drop(&mut self.inner) }
49+
drop(guard);
4950
}
5051
}

src/lib.rs

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ impl<T: ?Sized> InterruptRefCell<T> {
266266
#[inline]
267267
#[cfg_attr(feature = "debug_interruptrefcell", track_caller)]
268268
pub fn try_borrow(&self) -> Result<InterruptRef<'_, T>, BorrowError> {
269-
let _guard = interrupts::disable();
269+
let guard = interrupts::disable();
270270
self.inner.try_borrow().map(|inner| {
271271
let inner = InterruptDropper::from(inner);
272-
InterruptRef { inner, _guard }
272+
InterruptRef { inner, guard }
273273
})
274274
}
275275

@@ -337,10 +337,10 @@ impl<T: ?Sized> InterruptRefCell<T> {
337337
#[inline]
338338
#[cfg_attr(feature = "debug_interruptrefcell", track_caller)]
339339
pub fn try_borrow_mut(&self) -> Result<InterruptRefMut<'_, T>, BorrowMutError> {
340-
let _guard = interrupts::disable();
340+
let guard = interrupts::disable();
341341
self.inner.try_borrow_mut().map(|inner| {
342342
let inner = InterruptDropper::from(inner);
343-
InterruptRefMut { inner, _guard }
343+
InterruptRefMut { inner, guard }
344344
})
345345
}
346346

@@ -421,8 +421,10 @@ impl<T: ?Sized> InterruptRefCell<T> {
421421
/// ```
422422
#[inline]
423423
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError> {
424-
let _guard = interrupts::disable();
425-
self.inner.try_borrow_unguarded()
424+
let guard = interrupts::disable();
425+
let ret = self.inner.try_borrow_unguarded();
426+
drop(guard);
427+
ret
426428
}
427429
}
428430

@@ -554,7 +556,7 @@ impl<T> From<T> for InterruptRefCell<T> {
554556
/// See the [module-level documentation](self) for more.
555557
pub struct InterruptRef<'b, T: ?Sized + 'b> {
556558
inner: InterruptDropper<Ref<'b, T>>,
557-
_guard: interrupts::Guard,
559+
guard: interrupts::Guard,
558560
}
559561

560562
impl<T: ?Sized> Deref for InterruptRef<'_, T> {
@@ -579,9 +581,9 @@ impl<'b, T: ?Sized> InterruptRef<'b, T> {
579581
#[must_use]
580582
#[inline]
581583
pub fn clone(orig: &InterruptRef<'b, T>) -> InterruptRef<'b, T> {
582-
let _guard = interrupts::disable();
584+
let guard = interrupts::disable();
583585
let inner = InterruptDropper::from(Ref::clone(&orig.inner));
584-
InterruptRef { inner, _guard }
586+
InterruptRef { inner, guard }
585587
}
586588

587589
/// Makes a new `InterruptRef` for a component of the borrowed data.
@@ -607,9 +609,9 @@ impl<'b, T: ?Sized> InterruptRef<'b, T> {
607609
where
608610
F: FnOnce(&T) -> &U,
609611
{
610-
let InterruptRef { inner, _guard } = orig;
612+
let InterruptRef { inner, guard } = orig;
611613
let inner = InterruptDropper::from(Ref::map(InterruptDropper::into_inner(inner), f));
612-
InterruptRef { inner, _guard }
614+
InterruptRef { inner, guard }
613615
}
614616

615617
/// Makes a new `InterruptRef` for an optional component of the borrowed data. The
@@ -641,15 +643,15 @@ impl<'b, T: ?Sized> InterruptRef<'b, T> {
641643
where
642644
F: FnOnce(&T) -> Option<&U>,
643645
{
644-
let InterruptRef { inner, _guard } = orig;
646+
let InterruptRef { inner, guard } = orig;
645647
match Ref::filter_map(InterruptDropper::into_inner(inner), f) {
646648
Ok(inner) => {
647649
let inner = InterruptDropper::from(inner);
648-
Ok(InterruptRef { inner, _guard })
650+
Ok(InterruptRef { inner, guard })
649651
}
650652
Err(inner) => {
651653
let inner = InterruptDropper::from(inner);
652-
Err(InterruptRef { inner, _guard })
654+
Err(InterruptRef { inner, guard })
653655
}
654656
}
655657
}
@@ -682,16 +684,16 @@ impl<'b, T: ?Sized> InterruptRef<'b, T> {
682684
where
683685
F: FnOnce(&T) -> (&U, &V),
684686
{
685-
let _guard = interrupts::disable();
687+
let guard = interrupts::disable();
686688
let (a, b) = Ref::map_split(InterruptDropper::into_inner(orig.inner), f);
687689
(
688690
InterruptRef {
689691
inner: InterruptDropper::from(a),
690-
_guard,
692+
guard,
691693
},
692694
InterruptRef {
693695
inner: InterruptDropper::from(b),
694-
_guard: orig._guard,
696+
guard: orig.guard,
695697
},
696698
)
697699
}
@@ -738,9 +740,9 @@ impl<'b, T: ?Sized> InterruptRefMut<'b, T> {
738740
where
739741
F: FnOnce(&mut T) -> &mut U,
740742
{
741-
let InterruptRefMut { inner, _guard } = orig;
743+
let InterruptRefMut { inner, guard } = orig;
742744
let inner = InterruptDropper::from(RefMut::map(InterruptDropper::into_inner(inner), f));
743-
InterruptRefMut { inner, _guard }
745+
InterruptRefMut { inner, guard }
744746
}
745747

746748
/// Makes a new `InterruptRefMut` for an optional component of the borrowed data. The
@@ -780,15 +782,15 @@ impl<'b, T: ?Sized> InterruptRefMut<'b, T> {
780782
where
781783
F: FnOnce(&mut T) -> Option<&mut U>,
782784
{
783-
let InterruptRefMut { inner, _guard } = orig;
785+
let InterruptRefMut { inner, guard } = orig;
784786
match RefMut::filter_map(InterruptDropper::into_inner(inner), f) {
785787
Ok(inner) => {
786788
let inner = InterruptDropper::from(inner);
787-
Ok(InterruptRefMut { inner, _guard })
789+
Ok(InterruptRefMut { inner, guard })
788790
}
789791
Err(inner) => {
790792
let inner = InterruptDropper::from(inner);
791-
Err(InterruptRefMut { inner, _guard })
793+
Err(InterruptRefMut { inner, guard })
792794
}
793795
}
794796
}
@@ -826,16 +828,16 @@ impl<'b, T: ?Sized> InterruptRefMut<'b, T> {
826828
where
827829
F: FnOnce(&mut T) -> (&mut U, &mut V),
828830
{
829-
let _guard = interrupts::disable();
831+
let guard = interrupts::disable();
830832
let (a, b) = RefMut::map_split(InterruptDropper::into_inner(orig.inner), f);
831833
(
832834
InterruptRefMut {
833835
inner: InterruptDropper::from(a),
834-
_guard,
836+
guard,
835837
},
836838
InterruptRefMut {
837839
inner: InterruptDropper::from(b),
838-
_guard: orig._guard,
840+
guard: orig.guard,
839841
},
840842
)
841843
}
@@ -846,7 +848,7 @@ impl<'b, T: ?Sized> InterruptRefMut<'b, T> {
846848
/// See the [module-level documentation](self) for more.
847849
pub struct InterruptRefMut<'b, T: ?Sized + 'b> {
848850
inner: InterruptDropper<RefMut<'b, T>>,
849-
_guard: interrupts::Guard,
851+
guard: interrupts::Guard,
850852
}
851853

852854
impl<T: ?Sized> Deref for InterruptRefMut<'_, T> {

0 commit comments

Comments
 (0)