1
Fork 0

Add a helper for extending a span to include any trailing whitespace

This commit is contained in:
Michael Goulet 2024-04-07 19:38:05 -04:00
parent a439eb259d
commit 3253c021cb
7 changed files with 17 additions and 27 deletions

View file

@ -1592,8 +1592,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
.tcx
.sess
.source_map()
.span_extend_while(expr_span, char::is_whitespace)
.unwrap_or(expr_span)
.span_extend_while_whitespace(expr_span)
.shrink_to_hi()
.to(await_expr.span.shrink_to_hi());
err.span_suggestion(
@ -4851,10 +4850,7 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>(
let hir::IsAsync::Async(async_span) = sig.header.asyncness else {
return None;
};
let Ok(async_span) = tcx.sess.source_map().span_extend_while(async_span, |c| c.is_whitespace())
else {
return None;
};
let async_span = tcx.sess.source_map().span_extend_while_whitespace(async_span);
let future = tcx.hir_node_by_def_id(opaque_def_id).expect_item().expect_opaque_ty();
let [hir::GenericBound::Trait(trait_ref, _)] = future.bounds else {