about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/lib.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-02-13 03:07:18 +0000
committerJubilee Young <workingjubilee@gmail.com>2025-02-14 00:27:17 -0800
commitf6406dfd4efceb6f713e503aecda587304135ed9 (patch)
treea31b524ba2341d65c7985016a94db014d7459b52 /compiler/rustc_errors/src/lib.rs
parentb480a9214a7037813d29bc04d9e9dbe92ce10cf3 (diff)
downloadrust-f6406dfd4efceb6f713e503aecda587304135ed9.tar.gz
rust-f6406dfd4efceb6f713e503aecda587304135ed9.zip
Consider add-prefix replacements too
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
-rw-r--r--compiler/rustc_errors/src/lib.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 4a186565a7b..855b9734cdc 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -236,9 +236,10 @@ impl SubstitutionPart {
     /// it with "abx" is, since the "c" character is lost.
     pub fn is_destructive_replacement(&self, sm: &SourceMap) -> bool {
         self.is_replacement(sm)
-            && !sm
-                .span_to_snippet(self.span)
-                .is_ok_and(|snippet| self.snippet.trim_start().starts_with(snippet.trim_start()))
+            && !sm.span_to_snippet(self.span).is_ok_and(|snippet| {
+                self.snippet.trim_start().starts_with(snippet.trim_start())
+                    || self.snippet.trim_end().ends_with(snippet.trim_end())
+            })
     }
 
     fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool {