diff options
| author | Michael Goulet <michael@errs.io> | 2025-02-13 03:07:18 +0000 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2025-02-14 00:27:17 -0800 |
| commit | f6406dfd4efceb6f713e503aecda587304135ed9 (patch) | |
| tree | a31b524ba2341d65c7985016a94db014d7459b52 /compiler/rustc_errors/src/lib.rs | |
| parent | b480a9214a7037813d29bc04d9e9dbe92ce10cf3 (diff) | |
| download | rust-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.rs | 7 |
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 { |
