Skip to content

Conversation

@Muscraft
Copy link
Member

When rendering a "multi-line" suggestion with the Diff format, rustc uses a diff symbol for
any line that has a highlight part. This includes highlight parts that are highlighting nothing, i.e., a span of 0..0. This leads rustc to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that rustc will not add a diff symbol to lines that contain no changes/highlights.

Note: This PR is part of my ongoing effort to have rustc use annotate-snippets for rendering. This change will make it so that rustc and annotate-snippets will match in this case.

@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Muscraft Muscraft force-pushed the fix-diff-symbol-unchanged-lines branch from da86f5e to c7f014d Compare October 22, 2025 21:31
@fmease
Copy link
Member

fmease commented Oct 22, 2025

Thanks! @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 22, 2025

📌 Commit c7f014d has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 22, 2025
@fmease fmease assigned fmease and unassigned nnethercote Oct 22, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 22, 2025
…-lines, r=fmease

fix: Don't add diff symbol to unchanged lines

When rendering a "multi-line" suggestion with the [`Diff`](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L3078) format, `rustc` uses a [diff symbol](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L3017-L3022) for
[any line that has a highlight part](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L2705-L2713). This includes highlight parts that are highlighting nothing, i.e., a span of `0..0`. This leads `rustc` to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that `rustc` will not add a diff symbol to lines that contain no changes/highlights.

Note: This PR is part of my ongoing effort to have `rustc` use `annotate-snippets` for rendering. This change will make it so that `rustc` and `annotate-snippets` will match in this case.
bors added a commit that referenced this pull request Oct 23, 2025
Rollup of 4 pull requests

Successful merges:

 - #115501 (Add new inherit_handles flag to CommandExt trait)
 - #146629 (std: reorganize the UNIX-internal `weak` module)
 - #147762 (feat(rustdoc): `--emit=depinfo` output to stdout via `-`)
 - #148001 (fix: Don't add diff symbol to unchanged lines)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2f7e07b into rust-lang:master Oct 23, 2025
11 checks passed
rust-timer added a commit that referenced this pull request Oct 23, 2025
Rollup merge of #148001 - Muscraft:fix-diff-symbol-unchanged-lines, r=fmease

fix: Don't add diff symbol to unchanged lines

When rendering a "multi-line" suggestion with the [`Diff`](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L3078) format, `rustc` uses a [diff symbol](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L3017-L3022) for
[any line that has a highlight part](https://github.com/rust-lang/rust/blob/dc1feabef242259d61bd930713de3250577c1c71/compiler/rustc_errors/src/emitter.rs#L2705-L2713). This includes highlight parts that are highlighting nothing, i.e., a span of `0..0`. This leads `rustc` to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that `rustc` will not add a diff symbol to lines that contain no changes/highlights.

Note: This PR is part of my ongoing effort to have `rustc` use `annotate-snippets` for rendering. This change will make it so that `rustc` and `annotate-snippets` will match in this case.
@rustbot rustbot added this to the 1.92.0 milestone Oct 23, 2025
@Muscraft Muscraft deleted the fix-diff-symbol-unchanged-lines branch October 23, 2025 05:08
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 25, 2025
…szelmann

chore: Update to the latest annotate-snippets

This PR updates `annotate-snippets` to the latest version and updates the adapter code[^1] so that `AnnotateSnippetEmitter`'s output matches `HumanEmitter`'s output. If anyone would like to see the differences[^2] between `AnnotateSnippetEmitter` and `HumanEmitter`, [I have a branch](https://github.com/Muscraft/rust/tree/annotate-snippets-default-renderer) where `AnnotateSnippetEmitter` is used in place of `HumanEmitter`.

[^1]: A lot of the adapter code changes are based on code for `HumanEmitter`.
[^2]: Some of the test differences will go away when rust-lang#148001 and rust-lang#148004 are merged.
rust-timer added a commit that referenced this pull request Oct 25, 2025
Rollup merge of #148007 - Muscraft:annotate-snippets, r=jdonszelmann

chore: Update to the latest annotate-snippets

This PR updates `annotate-snippets` to the latest version and updates the adapter code[^1] so that `AnnotateSnippetEmitter`'s output matches `HumanEmitter`'s output. If anyone would like to see the differences[^2] between `AnnotateSnippetEmitter` and `HumanEmitter`, [I have a branch](https://github.com/Muscraft/rust/tree/annotate-snippets-default-renderer) where `AnnotateSnippetEmitter` is used in place of `HumanEmitter`.

[^1]: A lot of the adapter code changes are based on code for `HumanEmitter`.
[^2]: Some of the test differences will go away when #148001 and #148004 are merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants