diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-01 01:09:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 01:09:47 +0200 |
| commit | 1b262b8b5660bc70530f647822b477a8d56e1f4e (patch) | |
| tree | 41299c6d6c037d6b6addf13a984f9220fba45cd0 /compiler/rustc_borrowck | |
| parent | 9ecda8de85ce893cc3fc748ab06be0b8250147a7 (diff) | |
| parent | 6d6c90443182e18fb23c08cd2d97dae701d7b453 (diff) | |
| download | rust-1b262b8b5660bc70530f647822b477a8d56e1f4e.tar.gz rust-1b262b8b5660bc70530f647822b477a8d56e1f4e.zip | |
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/messages.ftl | 9 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mod.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_borrowck/src/session_diagnostics.rs | 8 |
3 files changed, 32 insertions, 6 deletions
diff --git a/compiler/rustc_borrowck/messages.ftl b/compiler/rustc_borrowck/messages.ftl index 0b8123c9703..4a616dc2464 100644 --- a/compiler/rustc_borrowck/messages.ftl +++ b/compiler/rustc_borrowck/messages.ftl @@ -203,6 +203,15 @@ borrowck_moved_due_to_method_call = *[false] call } +borrowck_moved_due_to_await = + {$place_name} {$is_partial -> + [true] partially moved + *[false] moved + } due to this {$is_loop_message -> + [true] await, in previous iteration of loop + *[false] await + } + borrowck_value_moved_here = value {$is_partial -> [true] partially moved diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 4243ec214b0..a780255725e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1085,12 +1085,21 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } } } else { - err.subdiagnostic(CaptureReasonLabel::MethodCall { - fn_call_span, - place_name: &place_name, - is_partial, - is_loop_message, - }); + if let Some((CallDesugaringKind::Await, _)) = desugaring { + err.subdiagnostic(CaptureReasonLabel::Await { + fn_call_span, + place_name: &place_name, + is_partial, + is_loop_message, + }); + } else { + err.subdiagnostic(CaptureReasonLabel::MethodCall { + fn_call_span, + place_name: &place_name, + is_partial, + is_loop_message, + }); + } // Erase and shadow everything that could be passed to the new infcx. let ty = moved_place.ty(self.body, tcx).ty; diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index bb95101845f..fceae5bb3ff 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -338,6 +338,14 @@ pub(crate) enum CaptureReasonLabel<'a> { is_partial: bool, is_loop_message: bool, }, + #[label(borrowck_moved_due_to_await)] + Await { + #[primary_span] + fn_call_span: Span, + place_name: &'a str, + is_partial: bool, + is_loop_message: bool, + }, #[label(borrowck_value_moved_here)] MovedHere { #[primary_span] |
