Fixing span manipulation and indentation of the suggestion introduced by #126187
According to comments: https://github.com/rust-lang/rust/pull/128084#issuecomment-2295254576 https://github.com/rust-lang/rust/pull/126187/files#r1634897691
This commit is contained in:
parent
739b1fdb15
commit
8750e24247
4 changed files with 20 additions and 32 deletions
|
@ -4667,10 +4667,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
if let hir::ExprKind::Block(b, _) = body.value.kind
|
||||
&& b.expr.is_none()
|
||||
{
|
||||
// The span of '}' in the end of block.
|
||||
let span = self.tcx.sess.source_map().end_point(b.span);
|
||||
sugg_spans.push((
|
||||
// The span will point to the closing curly brace `}` of the block.
|
||||
b.span.shrink_to_hi().with_lo(b.span.hi() - BytePos(1)),
|
||||
"\n Ok(())\n}".to_string(),
|
||||
span.shrink_to_lo(),
|
||||
format!(
|
||||
"{}{}",
|
||||
" Ok(())\n",
|
||||
self.tcx.sess.source_map().indentation_before(span).unwrap_or_default(),
|
||||
),
|
||||
));
|
||||
}
|
||||
err.multipart_suggestion_verbose(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue