提交 df0a16b2 编写于 作者: T Tyler Mandry

Include type info when available for awaited expr

上级 8ce334d5
......@@ -1378,10 +1378,10 @@ fn note_obligation_cause_for_async_await(
)
};
let push_target_span = |span: &mut MultiSpan| {
let push_target_span_with_fallback = |span: &mut MultiSpan, fallback: &str| {
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());
span.push_span_label(target_span, fallback.to_string());
} else {
span.push_span_label(target_span, format!("has type `{}`", target_ty));
}
......@@ -1390,10 +1390,12 @@ fn note_obligation_cause_for_async_await(
if let Some(await_span) = from_awaited_ty {
// The type causing this obligation is one being awaited at await_span.
let mut span = MultiSpan::from_span(await_span);
span.push_span_label(await_span, "await occurs here".to_string());
if target_span != await_span {
push_target_span(&mut span);
if target_span == await_span {
push_target_span_with_fallback(&mut span, "await occurs here");
} else {
span.push_span_label(await_span, "await occurs here".to_string());
push_target_span_with_fallback(&mut span, "created here");
}
err.span_note(
......@@ -1413,7 +1415,7 @@ fn note_obligation_cause_for_async_await(
format!("{} occurs here, with `{}` maybe used later", await_or_yield, snippet),
);
push_target_span(&mut span);
push_target_span_with_fallback(&mut span, "created here");
// If available, use the scope span to annotate the drop location.
if let Some(scope_span) = scope_span {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册