diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-26 01:49:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-26 01:49:00 +0200 |
| commit | 6228bd6ef6bc75400829bcb392d09e3b0e45ed20 (patch) | |
| tree | b127b9bf6bbcc69cc25dcb7e303ec8026eb8f619 /compiler/rustc_trait_selection/src | |
| parent | 621f2726fb20f6bed17ae183eeae8ca239af8d08 (diff) | |
| parent | 8750e2424744f6365fbbfd3a42059eb51091e736 (diff) | |
| download | rust-6228bd6ef6bc75400829bcb392d09e3b0e45ed20.tar.gz rust-6228bd6ef6bc75400829bcb392d09e3b0e45ed20.zip | |
Rollup merge of #129405 - surechen:fix_span_x, r=cjgillot
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
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 228b75cd73c..3cb95294fb6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4702,10 +4702,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( |
