about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPreston From <prestonfrom@gmail.com>2022-06-22 22:34:49 -0600
committerPreston From <prestonfrom@gmail.com>2022-06-22 22:34:49 -0600
commit1f707db0bf928454b699af1a2da745dfdbdeb680 (patch)
tree96985ed7ecc1fbee8752722711215bd31bad35be
parent2476100c857147c3402b1b7c05ed65a84ceb228e (diff)
downloadrust-1f707db0bf928454b699af1a2da745dfdbdeb680.tar.gz
rust-1f707db0bf928454b699af1a2da745dfdbdeb680.zip
Update messages for clarity when linting
-rw-r--r--clippy_lints/src/matches/significant_drop_in_scrutinee.rs8
-rw-r--r--tests/ui/significant_drop_in_scrutinee.stderr114
2 files changed, 64 insertions, 58 deletions
diff --git a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs
index 59ca33cbcc7..98884ac7d73 100644
--- a/clippy_lints/src/matches/significant_drop_in_scrutinee.rs
+++ b/clippy_lints/src/matches/significant_drop_in_scrutinee.rs
@@ -27,10 +27,10 @@ pub(super) fn check<'tcx>(
                 diag.span_label(s, "original temporary lives until here");
                 if let Some(spans) = has_significant_drop_in_arms(cx, arms) {
                     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);
     helper.find_sig_drop(scrutinee).map(|drops| {
         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 {
-            "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)
     })
diff --git a/tests/ui/significant_drop_in_scrutinee.stderr b/tests/ui/significant_drop_in_scrutinee.stderr
index 472f998ebf2..f97b606c474 100644
--- a/tests/ui/significant_drop_in_scrutinee.stderr
+++ b/tests/ui/significant_drop_in_scrutinee.stderr
@@ -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
    |
 LL |     match mutex.lock().unwrap().foo() {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         true => {
 LL |             mutex.lock().unwrap().bar();
-   |             --------------------- significant drop in arm here
+   |             --------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - original temporary lives until here
@@ -18,14 +18,14 @@ LL ~     let value = mutex.lock().unwrap().foo();
 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
    |
 LL |     match 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 |     }
    |      - original temporary lives until here
@@ -37,14 +37,14 @@ LL ~     let value = s.lock_m().get_the_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
    |
 LL |     match s.lock_m_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 |     }
    |      - original temporary lives until here
@@ -56,7 +56,7 @@ LL ~     let value = s.lock_m_m().get_the_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
    |
 LL |     match counter.temp_increment().len() {
@@ -65,20 +65,21 @@ LL |     match counter.temp_increment().len() {
 LL |     };
    |      - original 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 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
    |
 LL |         match (mutex1.lock().unwrap().s.len(), true) {
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL |                 mutex1.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - original temporary lives until here
@@ -90,14 +91,14 @@ LL ~         let value = mutex1.lock().unwrap().s.len();
 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
    |
 LL |         match (true, mutex1.lock().unwrap().s.len(), true) {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL |                 mutex1.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - original temporary lives until here
@@ -109,16 +110,16 @@ LL ~         let value = mutex1.lock().unwrap().s.len();
 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
    |
 LL |         match (mutex1.lock().unwrap().s.len(), true, mutex2.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();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - 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()) {
    |
 
-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
    |
 LL |         match (mutex1.lock().unwrap().s.len(), true, mutex2.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();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - 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) {
    |
 
-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
    |
 LL |         match mutex3.lock().unwrap().s.as_str() {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL |                 mutex1.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 LL |                 mutex2.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - 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:264:22
    |
 LL |         match (true, mutex3.lock().unwrap().s.as_str()) {
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...
 LL |                 mutex1.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 LL |                 mutex2.lock().unwrap().s.len();
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |         };
    |          - 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:283:11
    |
 LL |     match mutex.lock().unwrap().s.len() > 1 {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         true => {
 LL |             mutex.lock().unwrap().s.len();
-   |             --------------------- significant drop in arm here
+   |             --------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - original temporary lives until here
@@ -202,14 +203,14 @@ LL ~     let value = mutex.lock().unwrap().s.len() > 1;
 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
    |
 LL |     match 1 < mutex.lock().unwrap().s.len() {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         true => {
 LL |             mutex.lock().unwrap().s.len();
-   |             --------------------- significant drop in arm here
+   |             --------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - original temporary lives until here
@@ -221,16 +222,16 @@ LL ~     let value = 1 < mutex.lock().unwrap().s.len();
 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
    |
 LL |     match mutex1.lock().unwrap().s.len() < mutex2.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()
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - 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 {
    |
 
-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
    |
 LL |     match mutex1.lock().unwrap().s.len() >= mutex2.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()
-   |                 ---------------------- significant drop in arm here
+   |                 ---------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - original temporary lives until here
@@ -263,14 +264,14 @@ LL ~     let value = mutex1.lock().unwrap().s.len() >= mutex2.lock().unwrap().s.
 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
    |
 LL |     match get_mutex_guard().s.len() > 1 {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         true => {
 LL |             mutex1.lock().unwrap().s.len();
-   |             ---------------------- significant drop in arm here
+   |             ---------------------- another temporary with significant `Drop` created here
 ...
 LL |     };
    |      - original temporary lives until here
@@ -282,7 +283,7 @@ LL ~     let value = get_mutex_guard().s.len() > 1;
 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
    |
 LL |       match match i {
@@ -296,7 +297,7 @@ LL | |         > 1
    | |___________^
 ...
 LL |               mutex1.lock().unwrap().s.len();
-   |               ---------------------- significant drop in arm here
+   |               ---------------------- another temporary with significant `Drop` created here
 ...
 LL |       };
    |        - original temporary lives until here
@@ -312,7 +313,7 @@ LL +     .s
 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
    |
 LL |       match if i > 1 {
@@ -326,7 +327,7 @@ LL | |         > 1
    | |___________^
 ...
 LL |               mutex1.lock().unwrap().s.len();
-   |               ---------------------- significant drop in arm here
+   |               ---------------------- another temporary with significant `Drop` created here
 ...
 LL |       };
    |        - original temporary lives until here
@@ -342,14 +343,14 @@ LL +     }
 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
    |
 LL |     match s.lock().deref().deref() {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         0 | 1 => println!("Value was less than 2"),
 LL |         _ => println!("Value is {}", s.lock().deref()),
-   |                                      ---------------- significant drop in arm here
+   |                                      ---------------- another temporary with significant `Drop` created here
 LL |     };
    |      - original temporary lives until here
    |
@@ -360,27 +361,27 @@ LL ~     let value = *s.lock().deref().deref();
 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
    |
 LL |     match s.lock().deref().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 |     };
    |      - 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:498:11
    |
 LL |     match mutex.lock().unwrap().i = i {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         _ => {
 LL |             println!("{}", mutex.lock().unwrap().i);
-   |                            --------------------- significant drop in arm here
+   |                            --------------------- another temporary with significant `Drop` created here
 LL |         },
 LL |     };
    |      - original temporary lives until here
@@ -392,14 +393,14 @@ LL ~     mutex.lock().unwrap().i = i;
 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
    |
 LL |     match i = mutex.lock().unwrap().i {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         _ => {
 LL |             println!("{}", mutex.lock().unwrap().i);
-   |                            --------------------- significant drop in arm here
+   |                            --------------------- another temporary with significant `Drop` created here
 LL |         },
 LL |     };
    |      - original temporary lives until here
@@ -411,14 +412,14 @@ LL ~     i = mutex.lock().unwrap().i;
 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
    |
 LL |     match mutex.lock().unwrap().i += 1 {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         _ => {
 LL |             println!("{}", mutex.lock().unwrap().i);
-   |                            --------------------- significant drop in arm here
+   |                            --------------------- another temporary with significant `Drop` created here
 LL |         },
 LL |     };
    |      - original temporary lives until here
@@ -430,14 +431,14 @@ LL ~     mutex.lock().unwrap().i += 1;
 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
    |
 LL |     match i += mutex.lock().unwrap().i {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |         _ => {
 LL |             println!("{}", mutex.lock().unwrap().i);
-   |                            --------------------- significant drop in arm here
+   |                            --------------------- another temporary with significant `Drop` created here
 LL |         },
 LL |     };
    |      - original temporary lives until here
@@ -449,7 +450,7 @@ LL ~     i += mutex.lock().unwrap().i;
 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
    |
 LL |     match rwlock.read().unwrap().to_number() {
@@ -457,8 +458,10 @@ LL |     match rwlock.read().unwrap().to_number() {
 ...
 LL |     };
    |      - 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
    |
 LL |     for s in rwlock.read().unwrap().iter() {
@@ -466,8 +469,10 @@ LL |     for s in rwlock.read().unwrap().iter() {
 LL |         println!("{}", s);
 LL |     }
    |      - 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
    |
 LL |     match mutex.lock().unwrap().foo() {
@@ -476,6 +481,7 @@ LL |     match mutex.lock().unwrap().foo() {
 LL |     };
    |      - original 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();