Skip to content

Commit df0a16b

Browse files
committed
Include type info when available for awaited expr
1 parent 8ce334d commit df0a16b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/librustc_trait_selection/traits/error_reporting/suggestions.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1378,10 +1378,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13781378
)
13791379
};
13801380

1381-
let push_target_span = |span: &mut MultiSpan| {
1381+
let push_target_span_with_fallback = |span: &mut MultiSpan, fallback: &str| {
13821382
if target_ty.is_impl_trait() {
13831383
// It's not very useful to tell the user the type if it's opaque.
1384-
span.push_span_label(target_span, "created here".to_string());
1384+
span.push_span_label(target_span, fallback.to_string());
13851385
} else {
13861386
span.push_span_label(target_span, format!("has type `{}`", target_ty));
13871387
}
@@ -1390,10 +1390,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13901390
if let Some(await_span) = from_awaited_ty {
13911391
// The type causing this obligation is one being awaited at await_span.
13921392
let mut span = MultiSpan::from_span(await_span);
1393-
span.push_span_label(await_span, "await occurs here".to_string());
13941393

1395-
if target_span != await_span {
1396-
push_target_span(&mut span);
1394+
if target_span == await_span {
1395+
push_target_span_with_fallback(&mut span, "await occurs here");
1396+
} else {
1397+
span.push_span_label(await_span, "await occurs here".to_string());
1398+
push_target_span_with_fallback(&mut span, "created here");
13971399
}
13981400

13991401
err.span_note(
@@ -1413,7 +1415,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
14131415
format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
14141416
);
14151417

1416-
push_target_span(&mut span);
1418+
push_target_span_with_fallback(&mut span, "created here");
14171419

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

0 commit comments

Comments
 (0)