From 58939b9520e71b6caa2ccc5ca28071e6379d39c0 Mon Sep 17 00:00:00 2001 From: IQuant Date: Tue, 14 Feb 2023 23:16:29 +0300 Subject: [PATCH] Specify correct spans in suggest_await_on_expect_found --- compiler/rustc_infer/src/errors/mod.rs | 8 +------- compiler/rustc_infer/src/infer/error_reporting/suggest.rs | 6 +++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_infer/src/errors/mod.rs b/compiler/rustc_infer/src/errors/mod.rs index f4af251d11f..0c2713fb1a7 100644 --- a/compiler/rustc_infer/src/errors/mod.rs +++ b/compiler/rustc_infer/src/errors/mod.rs @@ -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, }, diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs index b183abf977f..18c5097a262 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs @@ -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() {