Skip to content

Commit

Permalink
Specify correct spans in suggest_await_on_expect_found
Browse files Browse the repository at this point in the history
  • Loading branch information
IntQuant committed Feb 14, 2023
1 parent 5c7afde commit 58939b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 1 addition & 7 deletions compiler/rustc_infer/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_infer/src/infer/error_reporting/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 58939b9

Please sign in to comment.