Specify correct spans in suggest_await_on_expect_found

This commit is contained in:
IQuant 2023-02-14 23:16:29 +03:00
parent 5c7afde6f2
commit 58939b9520
2 changed files with 6 additions and 8 deletions

View File

@ -1072,14 +1072,8 @@ pub enum ConsiderAddingAwait {
#[primary_span]
span: Span,
},
#[suggestion(
infer_await_future,
code = ".await",
style = "verbose",
applicability = "maybe-incorrect"
)]
#[note(infer_await_note)]
FutureSuggWithNote {
FutureSuggNote {
#[primary_span]
span: Span,
},

View File

@ -223,7 +223,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
_ => Some(ConsiderAddingAwait::BothFuturesHelp),
},
(_, Some(ty)) if self.same_type_modulo_infer(exp_found.expected, ty) => {
Some(ConsiderAddingAwait::FutureSuggWithNote { span: exp_span.shrink_to_hi() })
// FIXME: Seems like we can't have a suggestion and a note with different spans in a single subdiagnostic
diag.subdiagnostic(ConsiderAddingAwait::FutureSugg {
span: exp_span.shrink_to_hi(),
});
Some(ConsiderAddingAwait::FutureSuggNote { span: exp_span })
}
(Some(ty), _) if self.same_type_modulo_infer(ty, exp_found.found) => match cause.code()
{