Skip to content

Commit 67fa36a

Browse files
committed
Auto merge of #12479 - y21:readonly_write_lock_perf, r=Jarcho
move `readonly_write_lock` to perf [There haven't been any issues](https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+readonly_write_lock) since its creation and it's a pretty useful lint I think, so I'd say it's worth giving it a try? Did a lintcheck run on 300 crates with no results, but I guess `RwLock` is usually not something that's used much in libraries. changelog: move [`readonly_write_lock`] to perf (now warn-by-default)
2 parents 12ecaa8 + adcbb4a commit 67fa36a

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3591,7 +3591,7 @@ declare_clippy_lint! {
35913591
/// ```
35923592
#[clippy::version = "1.73.0"]
35933593
pub READONLY_WRITE_LOCK,
3594-
nursery,
3594+
perf,
35953595
"acquiring a write lock when a read lock would work"
35963596
}
35973597

tests/ui/await_holding_lock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::await_holding_lock)]
2+
#![allow(clippy::readonly_write_lock)]
23

34
// When adding or modifying a test, please do the same for parking_lot::Mutex.
45
mod std_mutex {

tests/ui/await_holding_lock.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error: this `MutexGuard` is held across an `await` point
2-
--> tests/ui/await_holding_lock.rs:9:13
2+
--> tests/ui/await_holding_lock.rs:10:13
33
|
44
LL | let guard = x.lock().unwrap();
55
| ^^^^^
66
|
77
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
88
note: these are all the `await` points this lock is held through
9-
--> tests/ui/await_holding_lock.rs:11:15
9+
--> tests/ui/await_holding_lock.rs:12:15
1010
|
1111
LL | baz().await
1212
| ^^^^^
1313
= note: `-D clippy::await-holding-lock` implied by `-D warnings`
1414
= help: to override `-D warnings` add `#[allow(clippy::await_holding_lock)]`
1515

1616
error: this `MutexGuard` is held across an `await` point
17-
--> tests/ui/await_holding_lock.rs:25:13
17+
--> tests/ui/await_holding_lock.rs:26:13
1818
|
1919
LL | let guard = x.read().unwrap();
2020
| ^^^^^
2121
|
2222
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
2323
note: these are all the `await` points this lock is held through
24-
--> tests/ui/await_holding_lock.rs:27:15
24+
--> tests/ui/await_holding_lock.rs:28:15
2525
|
2626
LL | baz().await
2727
| ^^^^^
2828

2929
error: this `MutexGuard` is held across an `await` point
30-
--> tests/ui/await_holding_lock.rs:31:13
30+
--> tests/ui/await_holding_lock.rs:32:13
3131
|
3232
LL | let mut guard = x.write().unwrap();
3333
| ^^^^^^^^^
3434
|
3535
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
3636
note: these are all the `await` points this lock is held through
37-
--> tests/ui/await_holding_lock.rs:33:15
37+
--> tests/ui/await_holding_lock.rs:34:15
3838
|
3939
LL | baz().await
4040
| ^^^^^
4141

4242
error: this `MutexGuard` is held across an `await` point
43-
--> tests/ui/await_holding_lock.rs:53:13
43+
--> tests/ui/await_holding_lock.rs:54:13
4444
|
4545
LL | let guard = x.lock().unwrap();
4646
| ^^^^^
4747
|
4848
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
4949
note: these are all the `await` points this lock is held through
50-
--> tests/ui/await_holding_lock.rs:56:28
50+
--> tests/ui/await_holding_lock.rs:57:28
5151
|
5252
LL | let second = baz().await;
5353
| ^^^^^
@@ -56,79 +56,79 @@ LL | let third = baz().await;
5656
| ^^^^^
5757

5858
error: this `MutexGuard` is held across an `await` point
59-
--> tests/ui/await_holding_lock.rs:67:17
59+
--> tests/ui/await_holding_lock.rs:68:17
6060
|
6161
LL | let guard = x.lock().unwrap();
6262
| ^^^^^
6363
|
6464
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
6565
note: these are all the `await` points this lock is held through
66-
--> tests/ui/await_holding_lock.rs:69:19
66+
--> tests/ui/await_holding_lock.rs:70:19
6767
|
6868
LL | baz().await
6969
| ^^^^^
7070

7171
error: this `MutexGuard` is held across an `await` point
72-
--> tests/ui/await_holding_lock.rs:80:17
72+
--> tests/ui/await_holding_lock.rs:81:17
7373
|
7474
LL | let guard = x.lock().unwrap();
7575
| ^^^^^
7676
|
7777
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
7878
note: these are all the `await` points this lock is held through
79-
--> tests/ui/await_holding_lock.rs:82:19
79+
--> tests/ui/await_holding_lock.rs:83:19
8080
|
8181
LL | baz().await
8282
| ^^^^^
8383

8484
error: this `MutexGuard` is held across an `await` point
85-
--> tests/ui/await_holding_lock.rs:93:13
85+
--> tests/ui/await_holding_lock.rs:94:13
8686
|
8787
LL | let guard = x.lock();
8888
| ^^^^^
8989
|
9090
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
9191
note: these are all the `await` points this lock is held through
92-
--> tests/ui/await_holding_lock.rs:95:15
92+
--> tests/ui/await_holding_lock.rs:96:15
9393
|
9494
LL | baz().await
9595
| ^^^^^
9696

9797
error: this `MutexGuard` is held across an `await` point
98-
--> tests/ui/await_holding_lock.rs:109:13
98+
--> tests/ui/await_holding_lock.rs:110:13
9999
|
100100
LL | let guard = x.read();
101101
| ^^^^^
102102
|
103103
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
104104
note: these are all the `await` points this lock is held through
105-
--> tests/ui/await_holding_lock.rs:111:15
105+
--> tests/ui/await_holding_lock.rs:112:15
106106
|
107107
LL | baz().await
108108
| ^^^^^
109109

110110
error: this `MutexGuard` is held across an `await` point
111-
--> tests/ui/await_holding_lock.rs:115:13
111+
--> tests/ui/await_holding_lock.rs:116:13
112112
|
113113
LL | let mut guard = x.write();
114114
| ^^^^^^^^^
115115
|
116116
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
117117
note: these are all the `await` points this lock is held through
118-
--> tests/ui/await_holding_lock.rs:117:15
118+
--> tests/ui/await_holding_lock.rs:118:15
119119
|
120120
LL | baz().await
121121
| ^^^^^
122122

123123
error: this `MutexGuard` is held across an `await` point
124-
--> tests/ui/await_holding_lock.rs:137:13
124+
--> tests/ui/await_holding_lock.rs:138:13
125125
|
126126
LL | let guard = x.lock();
127127
| ^^^^^
128128
|
129129
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
130130
note: these are all the `await` points this lock is held through
131-
--> tests/ui/await_holding_lock.rs:140:28
131+
--> tests/ui/await_holding_lock.rs:141:28
132132
|
133133
LL | let second = baz().await;
134134
| ^^^^^
@@ -137,40 +137,40 @@ LL | let third = baz().await;
137137
| ^^^^^
138138

139139
error: this `MutexGuard` is held across an `await` point
140-
--> tests/ui/await_holding_lock.rs:151:17
140+
--> tests/ui/await_holding_lock.rs:152:17
141141
|
142142
LL | let guard = x.lock();
143143
| ^^^^^
144144
|
145145
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
146146
note: these are all the `await` points this lock is held through
147-
--> tests/ui/await_holding_lock.rs:153:19
147+
--> tests/ui/await_holding_lock.rs:154:19
148148
|
149149
LL | baz().await
150150
| ^^^^^
151151

152152
error: this `MutexGuard` is held across an `await` point
153-
--> tests/ui/await_holding_lock.rs:164:17
153+
--> tests/ui/await_holding_lock.rs:165:17
154154
|
155155
LL | let guard = x.lock();
156156
| ^^^^^
157157
|
158158
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
159159
note: these are all the `await` points this lock is held through
160-
--> tests/ui/await_holding_lock.rs:166:19
160+
--> tests/ui/await_holding_lock.rs:167:19
161161
|
162162
LL | baz().await
163163
| ^^^^^
164164

165165
error: this `MutexGuard` is held across an `await` point
166-
--> tests/ui/await_holding_lock.rs:185:9
166+
--> tests/ui/await_holding_lock.rs:186:9
167167
|
168168
LL | let mut guard = x.lock().unwrap();
169169
| ^^^^^^^^^
170170
|
171171
= help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
172172
note: these are all the `await` points this lock is held through
173-
--> tests/ui/await_holding_lock.rs:189:11
173+
--> tests/ui/await_holding_lock.rs:190:11
174174
|
175175
LL | baz().await;
176176
| ^^^^^

0 commit comments

Comments
 (0)