diff options
| author | bors <bors@rust-lang.org> | 2022-09-13 12:35:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-13 12:35:55 +0000 |
| commit | 5338f5f1d4ad9c99706e5cb691f8d5bbac341262 (patch) | |
| tree | 8dec5faa160a071b6e552792ad250c2127fd8e54 /compiler/rustc_errors/src/lib.rs | |
| parent | 7098c181f8447810fadb1776d3ffa3cdc93ce402 (diff) | |
| parent | 1c74d5041f2542fac7048207eb83e5ee035d5a75 (diff) | |
| download | rust-5338f5f1d4ad9c99706e5cb691f8d5bbac341262.tar.gz rust-5338f5f1d4ad9c99706e5cb691f8d5bbac341262.zip | |
Auto merge of #101757 - Dylan-DPC:rollup-wkt6oe9, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #101602 (Streamline `AttrAnnotatedTokenStream`) - #101690 (Avoid `Iterator::last`) - #101700 (A `SubstitutionPart` is not considered a deletion if it replaces nothing with nothing) - #101745 (Fix typo in concat_bytes documentation) - #101748 (rustdoc: remove redundant CSS `#source-sidebar, #sidebar-toggle`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index fb7ae6f99cf..888128f3f74 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -150,21 +150,20 @@ pub struct SubstitutionHighlight { impl SubstitutionPart { pub fn is_addition(&self, sm: &SourceMap) -> bool { - !self.snippet.is_empty() - && sm - .span_to_snippet(self.span) - .map_or(self.span.is_empty(), |snippet| snippet.trim().is_empty()) + !self.snippet.is_empty() && !self.replaces_meaningful_content(sm) } - pub fn is_deletion(&self) -> bool { - self.snippet.trim().is_empty() + pub fn is_deletion(&self, sm: &SourceMap) -> bool { + self.snippet.trim().is_empty() && self.replaces_meaningful_content(sm) } pub fn is_replacement(&self, sm: &SourceMap) -> bool { - !self.snippet.is_empty() - && sm - .span_to_snippet(self.span) - .map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty()) + !self.snippet.is_empty() && self.replaces_meaningful_content(sm) + } + + fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool { + sm.span_to_snippet(self.span) + .map_or(!self.span.is_empty(), |snippet| !snippet.trim().is_empty()) } } |
