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

Fix presentation of purely "additive" replacement suggestion parts #136958

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Feb 13, 2025

#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 #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

@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. labels Feb 13, 2025
@compiler-errors compiler-errors changed the title Use underline suggestions for purely 'additive' replacements Fix presentation of purely "additive" replacement suggestion parts Feb 13, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 13, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@@ -8,8 +8,7 @@ LL | true
= help: to override `-D warnings` add `#[allow(clippy::implicit_return)]`
help: add `return` as shown
|
LL - true
LL + return true
LL | return true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this renders strangely since it has no addition +'s, but it's exactly how it rendered before #127541, so it's a preexisting bug in the emitter.

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Feb 13, 2025

📌 Commit 1b5337c has been approved by estebank

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 13, 2025
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
Copy link
Member

Sequences with #136869 so one must be rebased over the other

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 14, 2025
@workingjubilee workingjubilee added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 14, 2025
@rust-log-analyzer

This comment has been minimized.

@workingjubilee workingjubilee added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Feb 14, 2025
@workingjubilee
Copy link
Member

rebased

@workingjubilee
Copy link
Member

@bors r=estebank

@bors
Copy link
Contributor

bors commented Feb 14, 2025

📌 Commit 6d71251 has been approved by estebank

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 14, 2025
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
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
…kingjubilee

Rollup of 10 pull requests

Successful merges:

 - rust-lang#135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test)
 - rust-lang#136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread)
 - rust-lang#136886 (Remove the common prelude module)
 - rust-lang#136938 (Remove `:` from `stack-protector-heuristics-effect.rs` Filecheck Pattern)
 - rust-lang#136956 (add vendor directory to .gitignore)
 - rust-lang#136958 (Fix presentation of purely "additive" replacement suggestion parts)
 - rust-lang#136967 (Use `slice::fill` in `io::Repeat` implementation)
 - rust-lang#136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr)
 - rust-lang#137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`)
 - rust-lang#137008 (Move code into `rustc_mir_transform`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 14, 2025
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#135778 (account for `c_enum_min_bits` in `multiple-reprs` UI test)
 - rust-lang#136052 (Correct comment for FreeBSD and DragonFly BSD in unix/thread)
 - rust-lang#136886 (Remove the common prelude module)
 - rust-lang#136956 (add vendor directory to .gitignore)
 - rust-lang#136958 (Fix presentation of purely "additive" replacement suggestion parts)
 - rust-lang#136967 (Use `slice::fill` in `io::Repeat` implementation)
 - rust-lang#136976 (alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr)
 - rust-lang#137007 (Emit MIR for each bit with on `dont_reset_cast_kind_without_updating_operand`)
 - rust-lang#137008 (Move code into `rustc_mir_transform`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 49fb61c into rust-lang:master Feb 14, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 14, 2025
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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2025
More sophisticated span trimming for suggestions

Previously rust-lang#136958 only cared about prefixes or suffixes. Now it detects more cases where a suggestion is "sandwiched" by unchanged code on the left or the right. Would be cool if we could detect several insertions, like `ACE` going to `ABCDE`, extracting `B` and `D`, but that seems unwieldy.

r? `@estebank`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2025
More sophisticated span trimming for suggestions

Previously rust-lang#136958 only cared about prefixes or suffixes. Now it detects more cases where a suggestion is "sandwiched" by unchanged code on the left or the right. Would be cool if we could detect several insertions, like `ACE` going to `ABCDE`, extracting `B` and `D`, but that seems unwieldy.

r? ``@estebank``
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2025
More sophisticated span trimming for suggestions

Previously rust-lang#136958 only cared about prefixes or suffixes. Now it detects more cases where a suggestion is "sandwiched" by unchanged code on the left or the right. Would be cool if we could detect several insertions, like `ACE` going to `ABCDE`, extracting `B` and `D`, but that seems unwieldy.

r? `@estebank`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 27, 2025
More sophisticated span trimming for suggestions

Previously rust-lang#136958 only cared about prefixes or suffixes. Now it detects more cases where a suggestion is "sandwiched" by unchanged code on the left or the right. Would be cool if we could detect several insertions, like `ACE` going to `ABCDE`, extracting `B` and `D`, but that seems unwieldy.

r? `@estebank`
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-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.

6 participants