Skip to content

Commit b731478

Browse files
committed
Don't annotate type when type is opaque
1 parent ce8331f commit b731478

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12381238
format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
12391239
);
12401240

1241-
span.push_span_label(target_span, format!("has type `{}`", target_ty));
1241+
if target_ty.is_impl_trait() {
1242+
// It's not very useful to tell the user the type if it's opaque.
1243+
span.push_span_label(target_span, "created here".to_string());
1244+
} else {
1245+
span.push_span_label(target_span, format!("has type `{}`", target_ty));
1246+
}
12421247

12431248
// If available, use the scope span to annotate the drop location.
12441249
if let Some(scope_span) = scope_span {

src/test/ui/async-await/async-fn-nonsend.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
1212
--> $DIR/async-fn-nonsend.rs:24:5
1313
|
1414
LL | let x = non_send();
15-
| - has type `impl std::fmt::Debug`
15+
| - created here
1616
LL | drop(x);
1717
LL | fut().await;
1818
| ^^^^^^^^^^^ 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
3333
--> $DIR/async-fn-nonsend.rs:33:20
3434
|
3535
LL | match Some(non_send()) {
36-
| ---------- has type `impl std::fmt::Debug`
36+
| ---------- created here
3737
LL | Some(_) => fut().await,
3838
| ^^^^^^^^^^^ await occurs here, with `non_send()` maybe used later
3939
...

src/test/ui/async-await/issue-68112.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an await
1212
--> $DIR/issue-68112.rs:32:9
1313
|
1414
LL | let non_send_fut = make_non_send_future1();
15-
| ------------ has type `impl std::future::Future`
15+
| ------------ created here
1616
LL | let _ = non_send_fut.await;
1717
LL | ready(0).await;
1818
| ^^^^^^^^ await occurs here, with `non_send_fut` maybe used later

src/test/ui/generator/issue-68112.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: future is not `Send` as this value is used across an yield
1212
--> $DIR/issue-68112.rs:31:9
1313
|
1414
LL | let _non_send_gen = make_non_send_generator();
15-
| ------------- has type `impl std::ops::Generator`
15+
| ------------- created here
1616
LL | yield;
1717
| ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
1818
LL | };

0 commit comments

Comments
 (0)