fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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