Skip to content

Commit e6077fc

Browse files
tweak removal span
1 parent f0fc4f9 commit e6077fc

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,15 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
15961596
// Peel off the DesugaringKind from the span
15971597
&& let Some(desugar_parent_span) = parent_expr.span.parent_callsite()
15981598
{
1599+
let removal_span = self.tcx
1600+
.sess
1601+
.source_map()
1602+
.span_extend_while(expr.span, char::is_whitespace)
1603+
.unwrap_or(expr.span)
1604+
.shrink_to_hi()
1605+
.to(desugar_parent_span);
15991606
err.span_suggestion(
1600-
self.tcx.sess.source.shrink_to_hi().to(desugar_parent_span),
1607+
removal_span,
16011608
"remove the `.await`",
16021609
"",
16031610
Applicability::MachineApplicable,

tests/ui/async-await/issue-101715.stderr

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
error[E0277]: `()` is not a future
22
--> $DIR/issue-101715.rs:11:10
33
|
4-
LL | S.very_long_method_name_the_longest_method_name_in_the_whole_universe()
5-
| ____________________________________________________________________________-
6-
LL | | .await
7-
| | ^^^^-
8-
| |__________|___|
9-
| | help: remove the `.await`
10-
| `()` is not a future
4+
LL | .await
5+
| -^^^^^
6+
| ||
7+
| |`()` is not a future
8+
| help: remove the `.await`
119
|
1210
= help: the trait `Future` is not implemented for `()`
1311
= note: () must be a future or must implement `IntoFuture` to be awaited

0 commit comments

Comments
 (0)