Skip to content

Commit

Permalink
Bless clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 23, 2023
1 parent d989e14 commit 6aa1268
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ async fn bad() -> u32 {
}

async fn bad_reason() -> u32 {
let _x = Ipv4Addr::new(127, 0, 0, 1);
baz().await
let x = Ipv4Addr::new(127, 0, 0, 1);
let y = baz().await;
let _x = x;
y
}

async fn good() -> u32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ LL | let _x = String::from("hello");
error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type.rs:10:9
|
LL | let _x = Ipv4Addr::new(127, 0, 0, 1);
| ^^
LL | let x = Ipv4Addr::new(127, 0, 0, 1);
| ^

error: `std::string::String` may not be held across an `await` point per `clippy.toml`
--> $DIR/await_holding_invalid_type.rs:31:13
--> $DIR/await_holding_invalid_type.rs:33:13
|
LL | let _x = String::from("hi!");
| ^^
Expand Down
137 changes: 48 additions & 89 deletions src/tools/clippy/tests/ui/await_holding_lock.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ LL | let guard = x.lock().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:9:9
--> $DIR/await_holding_lock.rs:11:15
|
LL | / let guard = x.lock().unwrap();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^
= note: `-D clippy::await-holding-lock` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]`

Expand All @@ -24,13 +21,10 @@ LL | let guard = x.read().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:25:9
--> $DIR/await_holding_lock.rs:27:15
|
LL | / let guard = x.read().unwrap();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:31:13
Expand All @@ -40,13 +34,10 @@ LL | let mut guard = x.write().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:31:9
--> $DIR/await_holding_lock.rs:33:15
|
LL | / let mut guard = x.write().unwrap();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:53:13
Expand All @@ -56,16 +47,13 @@ LL | let guard = x.lock().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:53:9
|
LL | / let guard = x.lock().unwrap();
LL | |
LL | |
LL | | let second = baz().await;
... |
LL | | first + second + third
LL | | }
| |_____^
--> $DIR/await_holding_lock.rs:56:28
|
LL | let second = baz().await;
| ^^^^^
LL |
LL | let third = baz().await;
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:67:17
Expand All @@ -75,13 +63,10 @@ LL | let guard = x.lock().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:67:13
--> $DIR/await_holding_lock.rs:69:19
|
LL | / let guard = x.lock().unwrap();
LL | |
LL | | baz().await
LL | | };
| |_________^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:80:17
Expand All @@ -91,13 +76,10 @@ LL | let guard = x.lock().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:80:13
--> $DIR/await_holding_lock.rs:82:19
|
LL | / let guard = x.lock().unwrap();
LL | |
LL | | baz().await
LL | | }
| |_________^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:93:13
Expand All @@ -107,13 +89,10 @@ LL | let guard = x.lock();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:93:9
--> $DIR/await_holding_lock.rs:95:15
|
LL | / let guard = x.lock();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:109:13
Expand All @@ -123,13 +102,10 @@ LL | let guard = x.read();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:109:9
--> $DIR/await_holding_lock.rs:111:15
|
LL | / let guard = x.read();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:115:13
Expand All @@ -139,13 +115,10 @@ LL | let mut guard = x.write();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:115:9
--> $DIR/await_holding_lock.rs:117:15
|
LL | / let mut guard = x.write();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:137:13
Expand All @@ -155,16 +128,13 @@ LL | let guard = x.lock();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:137:9
|
LL | / let guard = x.lock();
LL | |
LL | |
LL | | let second = baz().await;
... |
LL | | first + second + third
LL | | }
| |_____^
--> $DIR/await_holding_lock.rs:140:28
|
LL | let second = baz().await;
| ^^^^^
LL |
LL | let third = baz().await;
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:151:17
Expand All @@ -174,13 +144,10 @@ LL | let guard = x.lock();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:151:13
--> $DIR/await_holding_lock.rs:153:19
|
LL | / let guard = x.lock();
LL | |
LL | | baz().await
LL | | };
| |_________^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:164:17
Expand All @@ -190,13 +157,10 @@ LL | let guard = x.lock();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:164:13
--> $DIR/await_holding_lock.rs:166:19
|
LL | / let guard = x.lock();
LL | |
LL | | baz().await
LL | | }
| |_________^
LL | baz().await
| ^^^^^

error: this `MutexGuard` is held across an `await` point
--> $DIR/await_holding_lock.rs:185:9
Expand All @@ -206,15 +170,10 @@ LL | let mut guard = x.lock().unwrap();
|
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
--> $DIR/await_holding_lock.rs:185:5
|
LL | / let mut guard = x.lock().unwrap();
LL | |
LL | | *guard += 1;
LL | | drop(guard);
LL | | baz().await;
LL | | }
| |_^
--> $DIR/await_holding_lock.rs:189:11
|
LL | baz().await;
| ^^^^^

error: aborting due to 13 previous errors

67 changes: 23 additions & 44 deletions src/tools/clippy/tests/ui/await_holding_refcell_ref.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ LL | let b = x.borrow();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:6:5
--> $DIR/await_holding_refcell_ref.rs:8:11
|
LL | / let b = x.borrow();
LL | |
LL | | baz().await
LL | | }
| |_^
LL | baz().await
| ^^^^^
= note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::await_holding_refcell_ref)]`

Expand All @@ -24,13 +21,10 @@ LL | let b = x.borrow_mut();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:12:5
--> $DIR/await_holding_refcell_ref.rs:14:11
|
LL | / let b = x.borrow_mut();
LL | |
LL | | baz().await
LL | | }
| |_^
LL | baz().await
| ^^^^^

error: this `RefCell` reference is held across an `await` point
--> $DIR/await_holding_refcell_ref.rs:34:9
Expand All @@ -40,16 +34,13 @@ LL | let b = x.borrow_mut();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:34:5
|
LL | / let b = x.borrow_mut();
LL | |
LL | |
LL | | let second = baz().await;
... |
LL | | first + second + third
LL | | }
| |_^
--> $DIR/await_holding_refcell_ref.rs:37:24
|
LL | let second = baz().await;
| ^^^^^
LL |
LL | let third = baz().await;
| ^^^^^

error: this `RefCell` reference is held across an `await` point
--> $DIR/await_holding_refcell_ref.rs:47:9
Expand All @@ -59,16 +50,10 @@ LL | let b = x.borrow_mut();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:47:5
|
LL | / let b = x.borrow_mut();
LL | |
LL | |
LL | | let second = baz().await;
... |
LL | | first + second + third
LL | | }
| |_^
--> $DIR/await_holding_refcell_ref.rs:50:24
|
LL | let second = baz().await;
| ^^^^^

error: this `RefCell` reference is held across an `await` point
--> $DIR/await_holding_refcell_ref.rs:63:13
Expand All @@ -78,13 +63,10 @@ LL | let b = x.borrow_mut();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:63:9
--> $DIR/await_holding_refcell_ref.rs:65:15
|
LL | / let b = x.borrow_mut();
LL | |
LL | | baz().await
LL | | };
| |_____^
LL | baz().await
| ^^^^^

error: this `RefCell` reference is held across an `await` point
--> $DIR/await_holding_refcell_ref.rs:76:13
Expand All @@ -94,13 +76,10 @@ LL | let b = x.borrow_mut();
|
= help: ensure the reference is dropped before calling `await`
note: these are all the `await` points this reference is held through
--> $DIR/await_holding_refcell_ref.rs:76:9
--> $DIR/await_holding_refcell_ref.rs:78:15
|
LL | / let b = x.borrow_mut();
LL | |
LL | | baz().await
LL | | }
| |_____^
LL | baz().await
| ^^^^^

error: aborting due to 6 previous errors

1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ where
{
let rt = &t;
async { true }.await;
let _ = rt;
t
}

Expand Down
Loading

0 comments on commit 6aa1268

Please sign in to comment.