blob: 25cd9da73a1004675e789c5e4b110a80edc6b868 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
error: temporary with significant `Drop` can be early dropped
--> tests/ui/significant_drop_tightening.rs:10:9
|
LL | pub fn complex_return_triggers_the_lint() -> i32 {
| __________________________________________________-
LL | | fn foo() -> i32 {
LL | | 1
... |
LL | | let lock = mutex.lock().unwrap();
| | ^^^^
... |
LL | | foo()
LL | | }
| |_- temporary `lock` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
= note: `-D clippy::significant-drop-tightening` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::significant_drop_tightening)]`
help: drop the temporary after the end of its last usage
|
LL ~ let _ = *lock;
LL + drop(lock);
|
error: temporary with significant `Drop` can be early dropped
--> tests/ui/significant_drop_tightening.rs:105:13
|
LL | / {
LL | | let mutex = Mutex::new(1i32);
LL | | let lock = mutex.lock().unwrap();
| | ^^^^
... |
LL | | do_heavy_computation_that_takes_time((rslt0, rslt1));
LL | | }
| |_____- temporary `lock` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
help: drop the temporary after the end of its last usage
|
LL ~ let rslt1 = lock.is_positive();
LL + drop(lock);
|
error: temporary with significant `Drop` can be early dropped
--> tests/ui/significant_drop_tightening.rs:127:13
|
LL | / {
LL | | let mutex = Mutex::new(1i32);
LL | | let lock = mutex.lock().unwrap();
| | ^^^^
... |
LL | | do_heavy_computation_that_takes_time(rslt0);
LL | | }
| |_____- temporary `lock` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
help: merge the temporary construction with its single usage
|
LL ~
LL + let rslt0 = mutex.lock().unwrap().abs();
LL |
LL ~
|
error: temporary with significant `Drop` can be early dropped
--> tests/ui/significant_drop_tightening.rs:134:17
|
LL | / {
LL | | let mutex = Mutex::new(vec![1i32]);
LL | | let mut lock = mutex.lock().unwrap();
| | ^^^^
... |
LL | | do_heavy_computation_that_takes_time(());
LL | | }
| |_____- temporary `lock` is currently being dropped at the end of its contained scope
|
= note: this might lead to unnecessary resource contention
help: merge the temporary construction with its single usage
|
LL ~
LL + mutex.lock().unwrap().clear();
LL |
LL ~
|
error: aborting due to 4 previous errors
|