]> git.lizzy.rs Git - rust.git/commitdiff
Don't annotate type when type is opaque
authorTyler Mandry <tmandry@gmail.com>
Wed, 25 Mar 2020 02:25:40 +0000 (19:25 -0700)
committerTyler Mandry <tmandry@gmail.com>
Tue, 14 Apr 2020 01:48:55 +0000 (18:48 -0700)
src/librustc_trait_selection/traits/error_reporting/suggestions.rs
src/test/ui/async-await/async-fn-nonsend.stderr
src/test/ui/async-await/issue-68112.stderr
src/test/ui/generator/issue-68112.stderr

index 7d43a2273fed9e6e7f4a2cb325bb322e5e530737..7c29315352349c6733db8465884e668a0a15162b 100644 (file)
@@ -1353,7 +1353,12 @@ fn note_obligation_cause_for_async_await(
             format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
         );
 
-        span.push_span_label(target_span, format!("has type `{}`", target_ty));
+        if target_ty.is_impl_trait() {
+            // It's not very useful to tell the user the type if it's opaque.
+            span.push_span_label(target_span, "created here".to_string());
+        } else {
+            span.push_span_label(target_span, format!("has type `{}`", target_ty));
+        }
 
         // If available, use the scope span to annotate the drop location.
         if let Some(scope_span) = scope_span {
index 04df6203e43f1ecdf873e4ad078a20c4b6c21d3f..176c62fcd7d92ae4d632411707ba45eb22ba9643 100644 (file)
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/async-fn-nonsend.rs:24:5
    |
 LL |     let x = non_send();
-   |         - has type `impl std::fmt::Debug`
+   |         - created here
 LL |     drop(x);
 LL |     fut().await;
    |     ^^^^^^^^^^^ await occurs here, with `x` maybe used later
@@ -33,7 +33,7 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/async-fn-nonsend.rs:33:20
    |
 LL |     match Some(non_send()) {
-   |                ---------- has type `impl std::fmt::Debug`
+   |                ---------- created here
 LL |         Some(_) => fut().await,
    |                    ^^^^^^^^^^^ await occurs here, with `non_send()` maybe used later
 ...
index 9f901901e207efcda57c1196049b42e098906d59..eec2171024ac4b21a71a583879bd9f54439a27b7 100644 (file)
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
   --> $DIR/issue-68112.rs:32:9
    |
 LL |         let non_send_fut = make_non_send_future1();
-   |             ------------ has type `impl std::future::Future`
+   |             ------------ created here
 LL |         let _ = non_send_fut.await;
 LL |         ready(0).await;
    |         ^^^^^^^^ await occurs here, with `non_send_fut` maybe used later
index 8950ff707d4aa8d386c911a43c00111176babad1..273fec082cf8d0dfbb415a7974d92ab12c93b58c 100644 (file)
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an yield
   --> $DIR/issue-68112.rs:31:9
    |
 LL |         let _non_send_gen = make_non_send_generator();
-   |             ------------- has type `impl std::ops::Generator`
+   |             ------------- created here
 LL |         yield;
    |         ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
 LL |     };