Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show diff suggestion format on verbose replacement #127541

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jul 9, 2024

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |

before:

error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL +     let _ = 2.0f64;
   |               ~~~~

r? @oli-obk

@rustbot
Copy link
Collaborator

rustbot commented Jul 9, 2024

Some changes occurred in tests/ui/check-cfg

cc @Urgau

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 9, 2024
@estebank
Copy link
Contributor Author

estebank commented Jul 9, 2024

This is in response to #127407 (comment). This also highlights that there are multiple places where the suggestions could have more accurate spans. We should also improve the diff presentation to automatically skip pieces that haven't changed so that suggestions can continue to be built easily when possible.

@Urgau
Copy link
Member

Urgau commented Jul 10, 2024

Does the verbose suggestion highlight (in color mode) the thing being replaced?

What I mean is that before, the ^^^^ pointed directly at the offended place, now users will have to scan both lines to see the difference, at least without color; but with color on, we could show the character difference by highlighting them in bold/color/italic or whatever.

Adding a --color=always/SVG output test, might be helpful to see what most users will actually experience.

@bors

This comment was marked as resolved.

@estebank
Copy link
Contributor Author

estebank commented Jul 11, 2024

@oli-obk sorry about the last commit, it was an effort to simultaneously fix a papercut and have an SVG file to show different patch renderings, but even that backfired because GH can't render it :-/

I think it's failing because the contents are too long, I'll split it up and see.

Can easily remove it.

@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor Author

Does the verbose suggestion highlight (in color mode) the thing being replaced?

What I mean is that before, the ^^^^ pointed directly at the offended place, now users will have to scan both lines to see the difference, at least without color; but with color on, we could show the character difference by highlighting them in bold/color/italic or whatever.

Adding a --color=always/SVG output test, might be helpful to see what most users will actually experience.

@Urgau https://github.com/rust-lang/rust/blob/82684d02db0b89766a46f1efeb7f9214f690cb3c/tests/ui/suggestions/incorrect-variant-literal.svg

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@estebank
Copy link
Contributor Author

I'll move all the specific suggestion changes themselves to other PRs, but they will all clash with the diff output rendering change, so we'll have to be mindful of what lands first and then rebase properly.

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@bors
Copy link
Contributor

bors commented Feb 7, 2025

☔ The latest upstream changes (presumably #136697) made this pull request unmergeable. Please resolve the merge conflicts.

```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
  --> $DIR/attempted-access-non-fatal.rs:7:15
   |
LL |     let _ = 2.l;
   |               ^
   |
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
   |
LL -     let _ = 2.l;
LL +     let _ = 2.0f64;
   |
```
@estebank
Copy link
Contributor Author

@bors r=petrochenkov p=1

Raising priority to try and avoid more merge conflicts (given how many stderr files are being touched).

@bors
Copy link
Contributor

bors commented Feb 10, 2025

📌 Commit f0845ad has been approved by petrochenkov

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 Feb 10, 2025
@jieyouxu
Copy link
Member

@bors p=10 (conflict-prone)

@bors
Copy link
Contributor

bors commented Feb 11, 2025

⌛ Testing commit f0845ad with merge ffa9afe...

@bors
Copy link
Contributor

bors commented Feb 11, 2025

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing ffa9afe to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ffa9afe): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 4.6%, secondary 7.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
4.6% [4.6%, 4.6%] 1
Regressions ❌
(secondary)
7.2% [7.2%, 7.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.6% [4.6%, 4.6%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 786.626s -> 786.457s (-0.02%)
Artifact size: 348.30 MiB -> 348.34 MiB (0.01%)

@estebank
Copy link
Contributor Author

Apologies to all the PR authors coming to see what broke you. You just need to rebase + rebless.

@compiler-errors
Copy link
Member

compiler-errors commented Feb 13, 2025

It's pretty disappointing that this PR got no discussion before it was applied. I would've definitely pushed back on the fallout of this PR had I been aware of it past it landing and changing like every UI test. :(

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Feb 14, 2025
…nt, r=estebank

Fix presentation of purely "additive" replacement suggestion parts

rust-lang#127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced.

Consider:

```
LL -     Self::Baz: Clone,
LL +     Self::Baz: Clone, T: std::clone::Clone
```

In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now.

Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of rust-lang#127541.

---

In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means.

---

r? estebank
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Feb 14, 2025
…nt, r=estebank

Fix presentation of purely "additive" replacement suggestion parts

rust-lang#127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced.

Consider:

```
LL -     Self::Baz: Clone,
LL +     Self::Baz: Clone, T: std::clone::Clone
```

In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now.

Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of rust-lang#127541.

---

In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means.

---

r? estebank
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 14, 2025
…nt, r=estebank

Fix presentation of purely "additive" replacement suggestion parts

rust-lang#127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced.

Consider:

```
LL -     Self::Baz: Clone,
LL +     Self::Baz: Clone, T: std::clone::Clone
```

In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now.

Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of rust-lang#127541.

---

In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means.

---

r? estebank
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
Rollup merge of rust-lang#136958 - compiler-errors:additive-replacmeent, r=estebank

Fix presentation of purely "additive" replacement suggestion parts

rust-lang#127541 changes replacement suggestions to use the "diff" view always, which I think is really verbose in cases where a replacement snippet is a "superset" of the snippet that is being replaced.

Consider:

```
LL -     Self::Baz: Clone,
LL +     Self::Baz: Clone, T: std::clone::Clone
```

In this code, we suggest replacing `", "` with `", T: std::clone::Clone"`. This is a consequence of how the snippet is constructed. I believe that since the string that is being replaced is a subset of the replacement string, it's not providing much value to present this as a diff. Users should be able to clearly understand what's being suggested here using the `~` underline view we've been suggesting for some time now.

Given that this affects ~100 tests out of the ~1000 UI tests affected, I expect this to be a pretty meaningful improvement of the fallout of rust-lang#127541.

---

In the last commit, this PR also "trims" replacement parts so that they are turned into their purely additive subset, if possible. See the diff for what this means.

---

r? estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.