Add a helper for extending a span to include any trailing whitespace
This commit is contained in:
parent
a439eb259d
commit
3253c021cb
7 changed files with 17 additions and 27 deletions
|
@ -766,8 +766,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
self.tcx
|
||||
.sess
|
||||
.source_map()
|
||||
.span_extend_while(last_expr.span, |c| c.is_whitespace())
|
||||
.ok()?
|
||||
.span_extend_while_whitespace(last_expr.span)
|
||||
.shrink_to_hi()
|
||||
.with_hi(last_stmt.span.hi())
|
||||
};
|
||||
|
@ -874,10 +873,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
format!(" {ident} ")
|
||||
};
|
||||
let left_span = sm.span_through_char(blk.span, '{').shrink_to_hi();
|
||||
(
|
||||
sm.span_extend_while(left_span, |c| c.is_whitespace()).unwrap_or(left_span),
|
||||
sugg,
|
||||
)
|
||||
(sm.span_extend_while_whitespace(left_span), sugg)
|
||||
};
|
||||
Some(SuggestRemoveSemiOrReturnBinding::Add { sp: span, code: sugg, ident: *ident })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue