Skip to content

Commit 6a6bf3b

Browse files
committed
fix: still check for dummy
1 parent 01e131f commit 6a6bf3b

File tree

4 files changed

+3
-24
lines changed

4 files changed

+3
-24
lines changed

clippy_lints/src/significant_drop_tightening.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> StmtsChecker<'ap, 'lc, 'others, 'stmt, 'tcx
246246
.any(|(id, _)| id == apa.first_block_hir_id);
247247
// last stmt is not dummy
248248
if let Some(last_stmt_span) = apa.last_stmt_span
249+
&& !last_stmt_span.is_dummy()
249250
// last stmt is not current
250251
&& last_stmt_span != self.ap.curr_stmt.span
251252
&& (block_equals_curr || block_is_ancestor)

tests/ui/significant_drop_tightening.fixed

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
drop(inner);#![warn(clippy::significant_drop_tightening)]
1+
#![warn(clippy::significant_drop_tightening)]
32

43
use std::sync::Mutex;
54

@@ -169,7 +168,6 @@ fn issue_15574() {
169168

170169
fn start_send(inner: &std::sync::Mutex<Inner<Operation>>, token: &mut Token) -> bool {
171170
let mut inner = inner.lock().unwrap();
172-
//~^ significant_drop_tightening
173171

174172
// If there's a waiting receiver, pair up with it.
175173
if let Some(operation) = inner.receivers.try_select() {

tests/ui/significant_drop_tightening.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ fn issue_15574() {
164164

165165
fn start_send(inner: &std::sync::Mutex<Inner<Operation>>, token: &mut Token) -> bool {
166166
let mut inner = inner.lock().unwrap();
167-
//~^ significant_drop_tightening
168167

169168
// If there's a waiting receiver, pair up with it.
170169
if let Some(operation) = inner.receivers.try_select() {

tests/ui/significant_drop_tightening.stderr

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,5 @@ LL |
8383
LL ~
8484
|
8585

86-
error: temporary with significant `Drop` can be early dropped
87-
--> tests/ui/significant_drop_tightening.rs:166:21
88-
|
89-
LL | fn start_send(inner: &std::sync::Mutex<Inner<Operation>>, token: &mut Token) -> bool {
90-
| ______________________________________________________________________________________________-
91-
LL | | let mut inner = inner.lock().unwrap();
92-
| | ^^^^^
93-
... |
94-
LL | | }
95-
| |_________- temporary `inner` is currently being dropped at the end of its contained scope
96-
|
97-
= note: this might lead to unnecessary resource contention
98-
help: drop the temporary after the end of its last usage
99-
--> /home/ada4a/dev/minor/clippy/tests/clippy.toml:1:1
100-
|
101-
LL +
102-
LL ~ drop(inner);# default config for tests, overrides clippy.toml at the project root
103-
|
104-
105-
error: aborting due to 5 previous errors
86+
error: aborting due to 4 previous errors
10687

0 commit comments

Comments
 (0)