mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
503 lines
18 KiB
Text
503 lines
18 KiB
Text
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:55:11
|
|
|
|
|
LL | match mutex.lock().unwrap().foo() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex.lock().unwrap().bar();
|
|
| --------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
= note: `-D clippy::significant-drop-in-scrutinee` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::significant_drop_in_scrutinee)]`
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex.lock().unwrap().foo();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:143:11
|
|
|
|
|
LL | match s.lock_m().get_the_value() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", s.lock_m().get_the_value());
|
|
| ---------- another value with significant `Drop` created here
|
|
...
|
|
LL | }
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = s.lock_m().get_the_value();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:166:11
|
|
|
|
|
LL | match s.lock_m_m().get_the_value() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", s.lock_m().get_the_value());
|
|
| ---------- another value with significant `Drop` created here
|
|
...
|
|
LL | }
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = s.lock_m_m().get_the_value();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:216:11
|
|
|
|
|
LL | match counter.temp_increment().len() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = counter.temp_increment().len();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:241:16
|
|
|
|
|
LL | match (mutex1.lock().unwrap().s.len(), true) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex1.lock().unwrap().s.len();
|
|
LL ~ match (value, true) {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:252:22
|
|
|
|
|
LL | match (true, mutex1.lock().unwrap().s.len(), true) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex1.lock().unwrap().s.len();
|
|
LL ~ match (true, value, true) {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:264:16
|
|
|
|
|
LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex1.lock().unwrap().s.len();
|
|
LL ~ match (value, true, mutex2.lock().unwrap().s.len()) {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:264:54
|
|
|
|
|
LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex2.lock().unwrap().s.len();
|
|
LL ~ match (mutex1.lock().unwrap().s.len(), true, value) {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:279:15
|
|
|
|
|
LL | match mutex3.lock().unwrap().s.as_str() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:291:22
|
|
|
|
|
LL | match (true, mutex3.lock().unwrap().s.as_str()) {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:312:11
|
|
|
|
|
LL | match mutex.lock().unwrap().s.len() > 1 {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex.lock().unwrap().s.len();
|
|
| --------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex.lock().unwrap().s.len() > 1;
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:321:11
|
|
|
|
|
LL | match 1 < mutex.lock().unwrap().s.len() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex.lock().unwrap().s.len();
|
|
| --------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = 1 < mutex.lock().unwrap().s.len();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:341:11
|
|
|
|
|
LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len(),
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len()
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:354:11
|
|
|
|
|
LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len(),
|
|
| ---------------------- another value with significant `Drop` created here
|
|
LL | mutex2.lock().unwrap().s.len()
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:391:11
|
|
|
|
|
LL | match get_mutex_guard().s.len() > 1 {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = get_mutex_guard().s.len() > 1;
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:410:11
|
|
|
|
|
LL | match match i {
|
|
| ___________^
|
|
LL | |
|
|
LL | |
|
|
LL | | 100 => mutex1.lock().unwrap(),
|
|
... |
|
|
LL | | .len()
|
|
LL | | > 1
|
|
| |___________^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = match i {
|
|
LL +
|
|
LL +
|
|
LL + 100 => mutex1.lock().unwrap(),
|
|
LL + _ => mutex2.lock().unwrap(),
|
|
LL + }
|
|
LL + .s
|
|
LL + .len()
|
|
LL + > 1;
|
|
LL ~ match value
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:438:11
|
|
|
|
|
LL | match if i > 1 {
|
|
| ___________^
|
|
LL | |
|
|
LL | |
|
|
LL | | mutex1.lock().unwrap()
|
|
... |
|
|
LL | | .len()
|
|
LL | | > 1
|
|
| |___________^
|
|
...
|
|
LL | mutex1.lock().unwrap().s.len();
|
|
| ---------------------- another value with significant `Drop` created here
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = if i > 1 {
|
|
LL +
|
|
LL +
|
|
LL + mutex1.lock().unwrap()
|
|
LL + } else {
|
|
LL + mutex2.lock().unwrap()
|
|
LL + }
|
|
LL + .s
|
|
LL + .len()
|
|
LL + > 1;
|
|
LL ~ match value
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:494:11
|
|
|
|
|
LL | match s.lock().deref().deref() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | _ => println!("Value is {}", s.lock().deref()),
|
|
| ---------------- another value with significant `Drop` created here
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match and create a copy
|
|
|
|
|
LL ~ let value = *s.lock().deref().deref();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:524:11
|
|
|
|
|
LL | match s.lock().deref().deref() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | matcher => println!("Value is {}", s.lock().deref()),
|
|
| ---------------- another value with significant `Drop` created here
|
|
LL | _ => println!("Value was not a match"),
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:545:11
|
|
|
|
|
LL | match mutex.lock().unwrap().i = i {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", mutex.lock().unwrap().i);
|
|
| --------------------- another value with significant `Drop` created here
|
|
LL | },
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ mutex.lock().unwrap().i = i;
|
|
LL ~ match () {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:553:11
|
|
|
|
|
LL | match i = mutex.lock().unwrap().i {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", mutex.lock().unwrap().i);
|
|
| --------------------- another value with significant `Drop` created here
|
|
LL | },
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ i = mutex.lock().unwrap().i;
|
|
LL ~ match () {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:561:11
|
|
|
|
|
LL | match mutex.lock().unwrap().i += 1 {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", mutex.lock().unwrap().i);
|
|
| --------------------- another value with significant `Drop` created here
|
|
LL | },
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ mutex.lock().unwrap().i += 1;
|
|
LL ~ match () {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:569:11
|
|
|
|
|
LL | match i += mutex.lock().unwrap().i {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | println!("{}", mutex.lock().unwrap().i);
|
|
| --------------------- another value with significant `Drop` created here
|
|
LL | },
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ i += mutex.lock().unwrap().i;
|
|
LL ~ match () {
|
|
|
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:634:11
|
|
|
|
|
LL | match rwlock.read().unwrap().to_number() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
|
|
error: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:646:14
|
|
|
|
|
LL | for s in rwlock.read().unwrap().iter() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | }
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
|
|
error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
|
|
--> tests/ui/significant_drop_in_scrutinee.rs:663:11
|
|
|
|
|
LL | match mutex.lock().unwrap().foo() {
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | };
|
|
| - temporary lives until here
|
|
|
|
|
= note: this might lead to deadlocks or other unexpected behavior
|
|
help: try moving the temporary above the match
|
|
|
|
|
LL ~ let value = mutex.lock().unwrap().foo();
|
|
LL ~ match value {
|
|
|
|
|
|
|
error: aborting due to 26 previous errors
|
|
|