diff options
| author | bors <bors@rust-lang.org> | 2024-06-25 23:29:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-25 23:29:58 +0000 |
| commit | 31f8b70d2e18a0339c034e44c52aa3791c29f53c (patch) | |
| tree | bea0cd4144368aab7e965e7558a74f2e9e5ffc94 /compiler/rustc_hir_analysis/src | |
| parent | fda509e817abeeecb5b76bc1de844f355675c81e (diff) | |
| parent | 812b8b42a1aa49957f9b339d2590d8ae175804ba (diff) | |
| download | rust-31f8b70d2e18a0339c034e44c52aa3791c29f53c.tar.gz rust-31f8b70d2e18a0339c034e44c52aa3791c29f53c.zip | |
Auto merge of #126951 - matthiaskrgr:rollup-xg0o4mc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #126618 (Mark assoc tys live only if the corresponding trait is live) - #126746 (Deny `use<>` for RPITITs) - #126868 (not use offset when there is not ends with brace) - #126884 (Do not ICE when suggesting dereferencing closure arg) - #126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level) - #126915 (Don't suggest awaiting in closure patterns) - #126943 (De-duplicate all consecutive native libs regardless of their options) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/mod.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 4d1b96d9c1b..8469cbbbc7d 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -211,11 +211,18 @@ fn missing_items_err( .collect::<Vec<_>>() .join("`, `"); - // `Span` before impl block closing brace. - let hi = full_impl_span.hi() - BytePos(1); - // Point at the place right before the closing brace of the relevant `impl` to suggest - // adding the associated item at the end of its body. - let sugg_sp = full_impl_span.with_lo(hi).with_hi(hi); + let sugg_sp = if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(full_impl_span) + && snippet.ends_with("}") + { + // `Span` before impl block closing brace. + let hi = full_impl_span.hi() - BytePos(1); + // Point at the place right before the closing brace of the relevant `impl` to suggest + // adding the associated item at the end of its body. + full_impl_span.with_lo(hi).with_hi(hi) + } else { + full_impl_span.shrink_to_hi() + }; + // Obtain the level of indentation ending in `sugg_sp`. let padding = tcx.sess.source_map().indentation_before(sugg_sp).unwrap_or_else(|| String::new()); |
