Skip to content

Remove logic to suggest clone of function output #128241

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 26, 2024

I can't exactly tell, but I believe that this suggestion is operating off of a heuristic that the lifetime of a function's input is correlated with the lifetime of a function's output in such a way that cloning would fix an error. I don't think that actually manages to hit the bar of "actually provides useful suggestions" most of the time.

Specifically, I've hit false-positives due to this suggestion twice when fixing ICEs in the compiler, so I don't think it's worthwhile having this logic around. Neither of the two affected UI tests are actually fixed by the suggestion.

@rustbot
Copy link
Collaborator

rustbot commented Jul 26, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
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

@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 Jul 26, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, this does look weird to me.

@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 27, 2024

📌 Commit e7eae53 has been approved by jieyouxu

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 Jul 27, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#125897 (from_ref, from_mut: clarify documentation)
 - rust-lang#128207 (improve error message when `global_asm!` uses `asm!` options)
 - rust-lang#128241 (Remove logic to suggest clone of function output)
 - rust-lang#128259 ([illumos/solaris] set MSG_NOSIGNAL while writing to sockets)
 - rust-lang#128262 (Delete `SimplifyArmIdentity` and `SimplifyBranchSame` tests)
 - rust-lang#128266 (update `rust.channel` default value documentation)
 - rust-lang#128267 (Add rustdoc GUI test to check title with and without search)
 - rust-lang#128271 (Disable jump threading of float equality)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ee25d99 into rust-lang:master Jul 27, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Jul 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 27, 2024
Rollup merge of rust-lang#128241 - compiler-errors:clone-sugg, r=jieyouxu

Remove logic to suggest clone of function output

I can't exactly tell, but I believe that this suggestion is operating off of a heuristic that the lifetime of a function's input is correlated with the lifetime of a function's output in such a way that cloning would fix an error. I don't think that actually manages to hit the bar of "actually provides useful suggestions" most of the time.

Specifically, I've hit false-positives due to this suggestion *twice* when fixing ICEs in the compiler, so I don't think it's worthwhile having this logic around. Neither of the two affected UI tests are actually fixed by the suggestion.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 31, 2024
…=estebank

Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks

Also remove a heck of a lot of weird hacks in `suggest_cloning` that I don't think we should have around.

I know this regresses tests, but I don't believe most of these suggestions were accurate, b/c:
1. They either produced type errors (e.g. turning `&x` into `x.clone()`)
2. They don't fix the issue
3. They fix the issue ostensibly, but introduce logic errors (e.g. cloning a `&mut Option<T>` to then `Option::take` out...)

Most of the suggestions are still wrong, but they're not particularly *less* wrong IMO.

Stacked on top of rust-lang#128241, which is an "obviously worth landing" subset of this PR.

r? estebank
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2024
Rollup merge of rust-lang#128244 - compiler-errors:move-clone-sugg, r=estebank

Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks

Also remove a heck of a lot of weird hacks in `suggest_cloning` that I don't think we should have around.

I know this regresses tests, but I don't believe most of these suggestions were accurate, b/c:
1. They either produced type errors (e.g. turning `&x` into `x.clone()`)
2. They don't fix the issue
3. They fix the issue ostensibly, but introduce logic errors (e.g. cloning a `&mut Option<T>` to then `Option::take` out...)

Most of the suggestions are still wrong, but they're not particularly *less* wrong IMO.

Stacked on top of rust-lang#128241, which is an "obviously worth landing" subset of this PR.

r? estebank
# for free to join this conversation on GitHub. Already have an account? # 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.

4 participants