Add #[must_use] to all guard types

This commit is contained in:
Ruihan Li
2024-06-30 23:46:56 +08:00
committed by Tate, Hongliang Tian
parent 9e4775d9e2
commit 57ecfa2fec
9 changed files with 19 additions and 6 deletions

View File

@ -122,7 +122,7 @@ impl<T> Producer<T> {
// Update the event of pollee in a critical region so that pollee
// always reflects the _true_ state of the underlying ring buffer
// regardless of any race conditions.
self.0.common.lock_event();
let _guard = self.0.common.lock_event();
let rb = this_end.rb();
if rb.is_full() {
@ -237,7 +237,7 @@ impl<T> Drop for Producer<T> {
fn drop(&mut self) {
self.shutdown();
self.0.common.lock_event();
let _guard = self.0.common.lock_event();
// When reading from a channel such as a pipe or a stream socket,
// POLLHUP merely indicates that the peer closed its end of the channel.
@ -261,7 +261,7 @@ impl<T> Consumer<T> {
// Update the event of pollee in a critical region so that pollee
// always reflects the _true_ state of the underlying ring buffer
// regardless of any race conditions.
self.0.common.lock_event();
let _guard = self.0.common.lock_event();
let rb = this_end.rb();
if rb.is_empty() {
@ -377,7 +377,7 @@ impl<T> Drop for Consumer<T> {
fn drop(&mut self) {
self.shutdown();
self.0.common.lock_event();
let _guard = self.0.common.lock_event();
// POLLERR is also set for a file descriptor referring to the write end of a pipe
// when the read end has been closed.

View File

@ -102,6 +102,8 @@ impl ProcessGroup {
/// A scoped lock for a process group.
///
/// It provides some public methods to prevent the exposure of the inner type.
#[clippy::has_significant_drop]
#[must_use]
pub struct ProcessGroupGuard<'a> {
inner: MutexGuard<'a, Inner>,
}