]> git.lizzy.rs Git - rust.git/commitdiff
Use a label instead of a note for the drop site to create denser diagnostics
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 12 Dec 2022 15:57:31 +0000 (15:57 +0000)
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 13 Dec 2022 10:08:46 +0000 (10:08 +0000)
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
src/test/ui/async-await/async-await-let-else.drop-tracking.stderr
src/test/ui/async-await/async-await-let-else.no-drop-tracking.stderr
src/test/ui/async-await/issue-70935-complex-spans.no_drop_tracking.stderr
src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.no_drop_tracking.stderr
src/test/ui/async-await/issues/issue-67893.stderr

index e45794ebc426e53bceb5257e6d7933bc1eda40dc..12f9851196c0f352c8fa24a5926a72d9222c6ad6 100644 (file)
@@ -2212,17 +2212,11 @@ fn note_obligation_cause_for_async_await(
                     interior_span,
                     format!("has type `{}` which {}", target_ty, trait_explanation),
                 );
-                // If available, use the scope span to annotate the drop location.
-                let mut scope_note = None;
                 if let Some(scope_span) = scope_span {
                     let scope_span = source_map.end_point(scope_span);
 
                     let msg = format!("{} is later dropped here", snippet);
-                    if source_map.is_multiline(yield_span.between(scope_span)) {
-                        span.push_span_label(scope_span, msg);
-                    } else {
-                        scope_note = Some((scope_span, msg));
-                    }
+                    span.push_span_label(scope_span, msg);
                 }
                 err.span_note(
                     span,
@@ -2231,9 +2225,6 @@ fn note_obligation_cause_for_async_await(
                         future_or_generator, trait_explanation, an_await_or_yield
                     ),
                 );
-                if let Some((span, msg)) = scope_note {
-                    err.span_note(span, &msg);
-                }
             };
         match interior_or_upvar_span {
             GeneratorInteriorOrUpvar::Interior(interior_span, interior_extra_info) => {
index 616623ee07759eeabd7c7fb4dc211d435aedd462..f0f5245a3b42ba5d395058ed9bad1037146056b0 100644 (file)
@@ -68,14 +68,10 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/async-await-let-else.rs:33:28
    |
 LL |         (Rc::new(()), bar().await);
-   |          -----------       ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
-   |          |
+   |          -----------       ^^^^^^ - `Rc::new(())` is later dropped here
+   |          |                 |
+   |          |                 await occurs here, with `Rc::new(())` maybe used later
    |          has type `Rc<()>` which is not `Send`
-note: `Rc::new(())` is later dropped here
-  --> $DIR/async-await-let-else.rs:33:35
-   |
-LL |         (Rc::new(()), bar().await);
-   |                                   ^
 note: required by a bound in `is_send`
   --> $DIR/async-await-let-else.rs:19:15
    |
index 7f93563e28842119a6b983edbf1418a09b5955ec..d3c5e80a30df443ee5cf66c942c445ba95cec701 100644 (file)
@@ -53,14 +53,10 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/async-await-let-else.rs:33:28
    |
 LL |         (Rc::new(()), bar().await);
-   |          -----------       ^^^^^^ await occurs here, with `Rc::new(())` maybe used later
-   |          |
+   |          -----------       ^^^^^^ - `Rc::new(())` is later dropped here
+   |          |                 |
+   |          |                 await occurs here, with `Rc::new(())` maybe used later
    |          has type `Rc<()>` which is not `Send`
-note: `Rc::new(())` is later dropped here
-  --> $DIR/async-await-let-else.rs:33:35
-   |
-LL |         (Rc::new(()), bar().await);
-   |                                   ^
 note: required by a bound in `is_send`
   --> $DIR/async-await-let-else.rs:19:15
    |
index 34b31198e4f613a16a485e4d1d5a0ea144e7f9e8..8036d82daa4a33f51f3dff008efa3c58b55c50bb 100644 (file)
@@ -12,14 +12,10 @@ LL |           baz(|| async{
    |  _____________-
 LL | |             foo(tx.clone());
 LL | |         }).await;
-   | |         - ^^^^^^ await occurs here, with the value maybe used later
-   | |_________|
+   | |         - ^^^^^^- the value is later dropped here
+   | |         | |
+   | |_________| await occurs here, with the value maybe used later
    |           has type `[closure@$DIR/issue-70935-complex-spans.rs:17:13: 17:15]` which is not `Send`
-note: the value is later dropped here
-  --> $DIR/issue-70935-complex-spans.rs:19:17
-   |
-LL |         }).await;
-   |                 ^
 
 error: aborting due to previous error
 
index ab196dca20cc460bbf61e21bcbdd6ad43eb384cb..1033fa6cc8b344c474a9c79b6d74fdaa9eb903e9 100644 (file)
@@ -13,14 +13,10 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/issue-65436-raw-ptr-not-send.rs:18:35
    |
 LL |         bar(Foo(std::ptr::null())).await;
-   |                 ----------------  ^^^^^^ await occurs here, with `std::ptr::null()` maybe used later
-   |                 |
+   |                 ----------------  ^^^^^^- `std::ptr::null()` is later dropped here
+   |                 |                 |
+   |                 |                 await occurs here, with `std::ptr::null()` maybe used later
    |                 has type `*const u8` which is not `Send`
-note: `std::ptr::null()` is later dropped here
-  --> $DIR/issue-65436-raw-ptr-not-send.rs:18:41
-   |
-LL |         bar(Foo(std::ptr::null())).await;
-   |                                         ^
 help: consider moving this into a `let` binding to create a shorter lived borrow
   --> $DIR/issue-65436-raw-ptr-not-send.rs:18:13
    |
index 316b6d06f932ac1189cbbe6370beb920c259a178..2ce68a782918cf064c449afedab10f6815a2f3e2 100644 (file)
@@ -9,14 +9,10 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/auxiliary/issue_67893.rs:9:26
    |
 LL |     f(*x.lock().unwrap()).await;
-   |        ----------------- ^^^^^^ await occurs here, with `x.lock().unwrap()` maybe used later
-   |        |
+   |        ----------------- ^^^^^^- `x.lock().unwrap()` is later dropped here
+   |        |                 |
+   |        |                 await occurs here, with `x.lock().unwrap()` maybe used later
    |        has type `MutexGuard<'_, ()>` which is not `Send`
-note: `x.lock().unwrap()` is later dropped here
-  --> $DIR/auxiliary/issue_67893.rs:9:32
-   |
-LL |     f(*x.lock().unwrap()).await;
-   |                                ^
 note: required by a bound in `g`
   --> $DIR/issue-67893.rs:6:14
    |