From f6406dfd4efceb6f713e503aecda587304135ed9 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 13 Feb 2025 03:07:18 +0000 Subject: Consider add-prefix replacements too --- compiler/rustc_errors/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_errors') 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 { -- cgit 1.4.1-3-g733a5