Update messages for clarity when linting

This commit is contained in:
Preston From 2022-06-22 22:34:49 -06:00
parent 2476100c85
commit 1f707db0bf
2 changed files with 64 additions and 58 deletions

View file

@ -27,10 +27,10 @@ pub(super) fn check<'tcx>(
diag.span_label(s, "original temporary lives until here"); diag.span_label(s, "original temporary lives until here");
if let Some(spans) = has_significant_drop_in_arms(cx, arms) { if let Some(spans) = has_significant_drop_in_arms(cx, arms) {
for span in spans { for span in spans {
diag.span_label(span, "significant drop in arm here"); diag.span_label(span, "another temporary with significant `Drop` created here");
} }
diag.note("this might lead to deadlocks or other unexpected behavior");
} }
diag.note("this might lead to deadlocks or other unexpected behavior");
}); });
} }
} }
@ -89,9 +89,9 @@ fn has_significant_drop_in_scrutinee<'tcx, 'a>(
let mut helper = SigDropHelper::new(cx); let mut helper = SigDropHelper::new(cx);
helper.find_sig_drop(scrutinee).map(|drops| { helper.find_sig_drop(scrutinee).map(|drops| {
let message = if source == MatchSource::Normal { let message = if source == MatchSource::Normal {
"temporary with drop impl with side effects in match scrutinee lives to end of block" "temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression"
} else { } else {
"temporary with drop impl with side effects in for loop condition lives to end of block" "temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression"
}; };
(drops, message) (drops, message)
}) })

View file

@ -1,11 +1,11 @@
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:59:11 --> $DIR/significant_drop_in_scrutinee.rs:59:11
| |
LL | match mutex.lock().unwrap().foo() { LL | match mutex.lock().unwrap().foo() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | true => { LL | true => {
LL | mutex.lock().unwrap().bar(); LL | mutex.lock().unwrap().bar();
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -18,14 +18,14 @@ LL ~ let value = mutex.lock().unwrap().foo();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:132:11 --> $DIR/significant_drop_in_scrutinee.rs:132:11
| |
LL | match s.lock_m().get_the_value() { LL | match s.lock_m().get_the_value() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | println!("{}", s.lock_m().get_the_value()); LL | println!("{}", s.lock_m().get_the_value());
| ---------- significant drop in arm here | ---------- another temporary with significant `Drop` created here
... ...
LL | } LL | }
| - original temporary lives until here | - original temporary lives until here
@ -37,14 +37,14 @@ LL ~ let value = s.lock_m().get_the_value();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:153:11 --> $DIR/significant_drop_in_scrutinee.rs:153:11
| |
LL | match s.lock_m_m().get_the_value() { LL | match s.lock_m_m().get_the_value() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | println!("{}", s.lock_m().get_the_value()); LL | println!("{}", s.lock_m().get_the_value());
| ---------- significant drop in arm here | ---------- another temporary with significant `Drop` created here
... ...
LL | } LL | }
| - original temporary lives until here | - original temporary lives until here
@ -56,7 +56,7 @@ LL ~ let value = s.lock_m_m().get_the_value();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:201:11 --> $DIR/significant_drop_in_scrutinee.rs:201:11
| |
LL | match counter.temp_increment().len() { LL | match counter.temp_increment().len() {
@ -65,20 +65,21 @@ LL | match counter.temp_increment().len() {
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
= note: this might lead to deadlocks or other unexpected behavior
help: try moving the temporary above the match help: try moving the temporary above the match
| |
LL ~ let value = counter.temp_increment().len(); LL ~ let value = counter.temp_increment().len();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:224:16 --> $DIR/significant_drop_in_scrutinee.rs:224:16
| |
LL | match (mutex1.lock().unwrap().s.len(), true) { LL | match (mutex1.lock().unwrap().s.len(), true) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -90,14 +91,14 @@ LL ~ let value = mutex1.lock().unwrap().s.len();
LL ~ match (value, true) { LL ~ match (value, true) {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:233:22 --> $DIR/significant_drop_in_scrutinee.rs:233:22
| |
LL | match (true, mutex1.lock().unwrap().s.len(), true) { LL | match (true, mutex1.lock().unwrap().s.len(), true) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -109,16 +110,16 @@ LL ~ let value = mutex1.lock().unwrap().s.len();
LL ~ match (true, value, true) { LL ~ match (true, value, true) {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:243:16 --> $DIR/significant_drop_in_scrutinee.rs:243:16
| |
LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len(); LL | mutex2.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -130,16 +131,16 @@ LL ~ let value = mutex1.lock().unwrap().s.len();
LL ~ match (value, true, mutex2.lock().unwrap().s.len()) { LL ~ match (value, true, mutex2.lock().unwrap().s.len()) {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:243:54 --> $DIR/significant_drop_in_scrutinee.rs:243:54
| |
LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) { LL | match (mutex1.lock().unwrap().s.len(), true, mutex2.lock().unwrap().s.len()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len(); LL | mutex2.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -151,46 +152,46 @@ LL ~ let value = mutex2.lock().unwrap().s.len();
LL ~ match (mutex1.lock().unwrap().s.len(), true, value) { LL ~ match (mutex1.lock().unwrap().s.len(), true, value) {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:254:15 --> $DIR/significant_drop_in_scrutinee.rs:254:15
| |
LL | match mutex3.lock().unwrap().s.as_str() { LL | match mutex3.lock().unwrap().s.as_str() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len(); LL | mutex2.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
= note: this might lead to deadlocks or other unexpected behavior = note: this might lead to deadlocks or other unexpected behavior
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:264:22 --> $DIR/significant_drop_in_scrutinee.rs:264:22
| |
LL | match (true, mutex3.lock().unwrap().s.as_str()) { LL | match (true, mutex3.lock().unwrap().s.as_str()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len(); LL | mutex2.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
= note: this might lead to deadlocks or other unexpected behavior = note: this might lead to deadlocks or other unexpected behavior
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:283:11 --> $DIR/significant_drop_in_scrutinee.rs:283:11
| |
LL | match mutex.lock().unwrap().s.len() > 1 { LL | match mutex.lock().unwrap().s.len() > 1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | true => { LL | true => {
LL | mutex.lock().unwrap().s.len(); LL | mutex.lock().unwrap().s.len();
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -202,14 +203,14 @@ LL ~ let value = mutex.lock().unwrap().s.len() > 1;
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:290:11 --> $DIR/significant_drop_in_scrutinee.rs:290:11
| |
LL | match 1 < mutex.lock().unwrap().s.len() { LL | match 1 < mutex.lock().unwrap().s.len() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | true => { LL | true => {
LL | mutex.lock().unwrap().s.len(); LL | mutex.lock().unwrap().s.len();
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -221,16 +222,16 @@ LL ~ let value = 1 < mutex.lock().unwrap().s.len();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:308:11 --> $DIR/significant_drop_in_scrutinee.rs:308:11
| |
LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() { LL | match mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.len() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(), LL | mutex1.lock().unwrap().s.len(),
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len() LL | mutex2.lock().unwrap().s.len()
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -242,16 +243,16 @@ LL ~ let value = mutex1.lock().unwrap().s.len() < mutex2.lock().unwrap().s.l
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:319:11 --> $DIR/significant_drop_in_scrutinee.rs:319:11
| |
LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() { LL | match mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.len() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... ...
LL | mutex1.lock().unwrap().s.len(), LL | mutex1.lock().unwrap().s.len(),
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
LL | mutex2.lock().unwrap().s.len() LL | mutex2.lock().unwrap().s.len()
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -263,14 +264,14 @@ LL ~ let value = mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:354:11 --> $DIR/significant_drop_in_scrutinee.rs:354:11
| |
LL | match get_mutex_guard().s.len() > 1 { LL | match get_mutex_guard().s.len() > 1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | true => { LL | true => {
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -282,7 +283,7 @@ LL ~ let value = get_mutex_guard().s.len() > 1;
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:371:11 --> $DIR/significant_drop_in_scrutinee.rs:371:11
| |
LL | match match i { LL | match match i {
@ -296,7 +297,7 @@ LL | | > 1
| |___________^ | |___________^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -312,7 +313,7 @@ LL + .s
LL + .len() LL + .len()
... ...
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:397:11 --> $DIR/significant_drop_in_scrutinee.rs:397:11
| |
LL | match if i > 1 { LL | match if i > 1 {
@ -326,7 +327,7 @@ LL | | > 1
| |___________^ | |___________^
... ...
LL | mutex1.lock().unwrap().s.len(); LL | mutex1.lock().unwrap().s.len();
| ---------------------- significant drop in arm here | ---------------------- another temporary with significant `Drop` created here
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -342,14 +343,14 @@ LL + }
LL + .s LL + .s
... ...
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:451:11 --> $DIR/significant_drop_in_scrutinee.rs:451:11
| |
LL | match s.lock().deref().deref() { LL | match s.lock().deref().deref() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
LL | 0 | 1 => println!("Value was less than 2"), LL | 0 | 1 => println!("Value was less than 2"),
LL | _ => println!("Value is {}", s.lock().deref()), LL | _ => println!("Value is {}", s.lock().deref()),
| ---------------- significant drop in arm here | ---------------- another temporary with significant `Drop` created here
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
@ -360,27 +361,27 @@ LL ~ let value = *s.lock().deref().deref();
LL ~ match value { LL ~ match value {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:479:11 --> $DIR/significant_drop_in_scrutinee.rs:479:11
| |
LL | match s.lock().deref().deref() { LL | match s.lock().deref().deref() {
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
LL | matcher => println!("Value is {}", s.lock().deref()), LL | matcher => println!("Value is {}", s.lock().deref()),
| ---------------- significant drop in arm here | ---------------- another temporary with significant `Drop` created here
LL | _ => println!("Value was not a match"), LL | _ => println!("Value was not a match"),
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
= note: this might lead to deadlocks or other unexpected behavior = note: this might lead to deadlocks or other unexpected behavior
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:498:11 --> $DIR/significant_drop_in_scrutinee.rs:498:11
| |
LL | match mutex.lock().unwrap().i = i { LL | match mutex.lock().unwrap().i = i {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | _ => { LL | _ => {
LL | println!("{}", mutex.lock().unwrap().i); LL | println!("{}", mutex.lock().unwrap().i);
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
LL | }, LL | },
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -392,14 +393,14 @@ LL ~ mutex.lock().unwrap().i = i;
LL ~ match () { LL ~ match () {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:504:11 --> $DIR/significant_drop_in_scrutinee.rs:504:11
| |
LL | match i = mutex.lock().unwrap().i { LL | match i = mutex.lock().unwrap().i {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | _ => { LL | _ => {
LL | println!("{}", mutex.lock().unwrap().i); LL | println!("{}", mutex.lock().unwrap().i);
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
LL | }, LL | },
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -411,14 +412,14 @@ LL ~ i = mutex.lock().unwrap().i;
LL ~ match () { LL ~ match () {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:510:11 --> $DIR/significant_drop_in_scrutinee.rs:510:11
| |
LL | match mutex.lock().unwrap().i += 1 { LL | match mutex.lock().unwrap().i += 1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | _ => { LL | _ => {
LL | println!("{}", mutex.lock().unwrap().i); LL | println!("{}", mutex.lock().unwrap().i);
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
LL | }, LL | },
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -430,14 +431,14 @@ LL ~ mutex.lock().unwrap().i += 1;
LL ~ match () { LL ~ match () {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:516:11 --> $DIR/significant_drop_in_scrutinee.rs:516:11
| |
LL | match i += mutex.lock().unwrap().i { LL | match i += mutex.lock().unwrap().i {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | _ => { LL | _ => {
LL | println!("{}", mutex.lock().unwrap().i); LL | println!("{}", mutex.lock().unwrap().i);
| --------------------- significant drop in arm here | --------------------- another temporary with significant `Drop` created here
LL | }, LL | },
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
@ -449,7 +450,7 @@ LL ~ i += mutex.lock().unwrap().i;
LL ~ match () { LL ~ match () {
| |
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:579:11 --> $DIR/significant_drop_in_scrutinee.rs:579:11
| |
LL | match rwlock.read().unwrap().to_number() { LL | match rwlock.read().unwrap().to_number() {
@ -457,8 +458,10 @@ LL | match rwlock.read().unwrap().to_number() {
... ...
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
|
= note: this might lead to deadlocks or other unexpected behavior
error: temporary with drop impl with side effects in for loop condition lives to end of block error: temporary with significant `Drop` in `for` loop condition will live until the end of the `for` expression
--> $DIR/significant_drop_in_scrutinee.rs:589:14 --> $DIR/significant_drop_in_scrutinee.rs:589:14
| |
LL | for s in rwlock.read().unwrap().iter() { LL | for s in rwlock.read().unwrap().iter() {
@ -466,8 +469,10 @@ LL | for s in rwlock.read().unwrap().iter() {
LL | println!("{}", s); LL | println!("{}", s);
LL | } LL | }
| - original temporary lives until here | - original temporary lives until here
|
= note: this might lead to deadlocks or other unexpected behavior
error: temporary with drop impl with side effects in match scrutinee lives to end of block error: temporary with significant `Drop` in `match` scrutinee will live until the end of the `match` expression
--> $DIR/significant_drop_in_scrutinee.rs:604:11 --> $DIR/significant_drop_in_scrutinee.rs:604:11
| |
LL | match mutex.lock().unwrap().foo() { LL | match mutex.lock().unwrap().foo() {
@ -476,6 +481,7 @@ LL | match mutex.lock().unwrap().foo() {
LL | }; LL | };
| - original temporary lives until here | - original temporary lives until here
| |
= note: this might lead to deadlocks or other unexpected behavior
help: try moving the temporary above the match help: try moving the temporary above the match
| |
LL ~ let value = mutex.lock().unwrap().foo(); LL ~ let value = mutex.lock().unwrap().foo();