Skip to content

Commit

Permalink
Fix clippy::empty_line_after_doc_comments and clippy::empty_line_afte…
Browse files Browse the repository at this point in the history
…r_outer_attr warnings

```
error: empty line after doc comment
   --> src/rwlock/raw.rs:99:5
    |
99  | /     /// Returns `true` iff an upgradable read lock was successfully acquired.
100 | |
    | |_^
101 |       pub(super) fn try_upgradable_read(&self) -> bool {
    |       ------------------------------------------------ the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]`
    = help: if the empty line is unintentional remove it

error: empty line after outer attribute
   --> src/rwlock/raw.rs:132:5
    |
132 | /     #[inline]
133 | |
    | |_^
134 |       pub(super) fn upgradable_read(&self) -> RawUpgradableRead<'_> {
    |       ------------------------------------------------------------- the attribute applies to this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
    = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]`
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:141:5
    |
141 | /     /// Returns `true` iff a write lock was successfully acquired.
142 | |
    | |_^
143 |       pub(super) fn try_write(&self) -> bool {
    |       -------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after outer attribute
   --> src/rwlock/raw.rs:165:5
    |
165 | /     #[inline]
166 | |
    | |_^
167 |       pub(super) fn write(&self) -> RawWrite<'_> {
    |       ------------------------------------------ the attribute applies to this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:182:5
    |
182 | /     /// This will attempt to upgrade it to a write lock.
183 | |
    | |_^
184 |       pub(super) unsafe fn try_upgrade(&self) -> bool {
    |       ----------------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:193:5
    |
193 | /     /// This will upgrade it to a write lock.
194 | |
    | |_^
195 |       pub(super) unsafe fn upgrade(&self) -> RawUpgrade<'_> {
    |       ----------------------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after outer attribute
   --> src/rwlock/raw.rs:211:5
    |
211 | /     #[inline]
212 | |
    | |_^
213 |       pub(super) unsafe fn downgrade_upgradable_read(&self) {
    |       ----------------------------------------------------- the attribute applies to this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_outer_attr
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:220:5
    |
220 | /     /// This will downgrade it to a read lock.
221 | |
    | |_^
222 |       pub(super) unsafe fn downgrade_write(&self) {
    |       ------------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:237:5
    |
237 | /     /// This will downgrade it to an upgradable read lock.
238 | |
    | |_^
239 |       pub(super) unsafe fn downgrade_to_upgradable(&self) {
    |       --------------------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:248:5
    |
248 | /     /// This will unlock that lock.
249 | |
    | |_^
250 |       pub(super) unsafe fn read_unlock(&self) {
    |       --------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:261:5
    |
261 | /     /// This will unlock that lock.
262 | |
    | |_^
263 |       pub(super) unsafe fn upgradable_read_unlock(&self) {
    |       -------------------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it

error: empty line after doc comment
   --> src/rwlock/raw.rs:277:5
    |
277 | /     /// This will unlock that lock.
278 | |
    | |_^
279 |       pub(super) unsafe fn write_unlock(&self) {
    |       ---------------------------------------- the comment documents this method
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments
    = help: if the empty line is unintentional remove it
```
  • Loading branch information
taiki-e committed Jan 19, 2025
1 parent 7819a20 commit cd0937d
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions src/rwlock/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ impl RawRwLock {
}

/// Returns `true` iff an upgradable read lock was successfully acquired.
pub(super) fn try_upgradable_read(&self) -> bool {
// First try grabbing the mutex.
let lock = if let Some(lock) = self.mutex.try_lock() {
Expand Down Expand Up @@ -130,7 +129,6 @@ impl RawRwLock {
}

#[inline]

pub(super) fn upgradable_read(&self) -> RawUpgradableRead<'_> {
RawUpgradableRead {
lock: self,
Expand All @@ -139,7 +137,6 @@ impl RawRwLock {
}

/// Returns `true` iff a write lock was successfully acquired.
pub(super) fn try_write(&self) -> bool {
// First try grabbing the mutex.
let lock = if let Some(lock) = self.mutex.try_lock() {
Expand All @@ -163,7 +160,6 @@ impl RawRwLock {
}

#[inline]

pub(super) fn write(&self) -> RawWrite<'_> {
RawWrite {
lock: self,
Expand All @@ -180,7 +176,6 @@ impl RawRwLock {
///
/// Caller must hold an upgradable read lock.
/// This will attempt to upgrade it to a write lock.
pub(super) unsafe fn try_upgrade(&self) -> bool {
self.state
.compare_exchange(ONE_READER, WRITER_BIT, Ordering::AcqRel, Ordering::Acquire)
Expand All @@ -191,7 +186,6 @@ impl RawRwLock {
///
/// Caller must hold an upgradable read lock.
/// This will upgrade it to a write lock.
pub(super) unsafe fn upgrade(&self) -> RawUpgrade<'_> {
// Set `WRITER_BIT` and decrement the number of readers at the same time.
self.state
Expand All @@ -209,7 +203,6 @@ impl RawRwLock {
/// Caller must hold an upgradable read lock.
/// This will downgrade it to a standard read lock.
#[inline]

pub(super) unsafe fn downgrade_upgradable_read(&self) {
self.mutex.unlock_unchecked();
}
Expand All @@ -218,7 +211,6 @@ impl RawRwLock {
///
/// Caller must hold a write lock.
/// This will downgrade it to a read lock.
pub(super) unsafe fn downgrade_write(&self) {
// Atomically downgrade state.
self.state
Expand All @@ -235,7 +227,6 @@ impl RawRwLock {
///
/// Caller must hold a write lock.
/// This will downgrade it to an upgradable read lock.
pub(super) unsafe fn downgrade_to_upgradable(&self) {
// Atomically downgrade state.
self.state
Expand All @@ -246,7 +237,6 @@ impl RawRwLock {
///
/// Caller must hold a read lock .
/// This will unlock that lock.
pub(super) unsafe fn read_unlock(&self) {
// Decrement the number of readers.
if self.state.fetch_sub(ONE_READER, Ordering::SeqCst) & !WRITER_BIT == ONE_READER {
Expand All @@ -259,7 +249,6 @@ impl RawRwLock {
///
/// Caller must hold an upgradable read lock.
/// This will unlock that lock.
pub(super) unsafe fn upgradable_read_unlock(&self) {
// Decrement the number of readers.
if self.state.fetch_sub(ONE_READER, Ordering::SeqCst) & !WRITER_BIT == ONE_READER {
Expand All @@ -275,7 +264,6 @@ impl RawRwLock {
///
/// Caller must hold a write lock.
/// This will unlock that lock.
pub(super) unsafe fn write_unlock(&self) {
// Unset `WRITER_BIT`.
self.state.fetch_and(!WRITER_BIT, Ordering::SeqCst);
Expand Down

0 comments on commit cd0937d

Please sign in to comment.