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

Suggest mut self: &mut Self for ?Sized impls #106410

Merged
merged 1 commit into from
Jan 8, 2023

Conversation

clubby789
Copy link
Contributor

Closes #106325
Closes #93078

The suggestion is probably not what the user wants (hence MaybeIncorrect) but at least makes the problem in the above issues clearer. It might be better to add a note explaining why this is the case, but I'm not sure how best to word that so this is a start.

@rustbot label +A-diagnostics

@rustbot
Copy link
Collaborator

rustbot commented Jan 3, 2023

r? @compiler-errors

(rustbot has picked a reviewer for you, use r? to override)

@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. A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 3, 2023
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 3, 2023

📌 Commit b40533999d808946faf2f325e11eb833a1ac49a9 has been approved by compiler-errors

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 Jan 3, 2023
@compiler-errors
Copy link
Member

Actually..... hm.... This is very likely not what the user wants, to the point that I think the suggestion may be misleading... Let me think about this a bit.

@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 Jan 3, 2023
@clubby789
Copy link
Contributor Author

Might it be more helpful here to suggest adding a where Self: Sized to the function? With a note specifying that &mut self can't be dereferenced as it may be unsized.

@compiler-errors
Copy link
Member

I would probably avoid doing any suggestion here, and explaining that &mut self is being auto-ref'd into &mut &mut self for some reason, which is probably not what the user intended.

@clubby789 clubby789 force-pushed the borrow-mut-self-mut-self-diag branch from b405339 to 6f97993 Compare January 5, 2023 16:32
@clubby789
Copy link
Contributor Author

I'm not entirely sure here about the wording, or if ?Sized impls are the only time this situation can happen. Hoping to explain both the error, and suggest why it might have happened.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 5, 2023
@clubby789 clubby789 force-pushed the borrow-mut-self-mut-self-diag branch from 6f97993 to 23c3a30 Compare January 5, 2023 16:51
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 8, 2023

📌 Commit 23c3a30 has been approved by compiler-errors

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 Jan 8, 2023
JohnTitor pushed a commit to JohnTitor/rust that referenced this pull request Jan 8, 2023
…-diag, r=compiler-errors

Suggest `mut self: &mut Self` for `?Sized` impls

Closes rust-lang#106325
Closes rust-lang#93078

The suggestion is _probably_ not what the user wants (hence `MaybeIncorrect`) but at least makes the problem in the above issues clearer. It might be better to add a note explaining why this is the case, but I'm not sure how best to word that so this is a start.

`@rustbot` label +A-diagnostics
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 8, 2023
Rollup of 8 pull requests

Successful merges:

 - rust-lang#103104 (Stabilize `main_separator_str`)
 - rust-lang#106410 (Suggest `mut self: &mut Self` for `?Sized` impls)
 - rust-lang#106457 (Adjust comments about pre-push.sh hook)
 - rust-lang#106546 (jsondoclint: Check local items in `paths` are also in `index`.)
 - rust-lang#106557 (Add some UI tests and reword error-code docs)
 - rust-lang#106562 (Clarify examples for `VecDeque::get/get_mut`)
 - rust-lang#106580 (remove unreachable error code `E0313`)
 - rust-lang#106581 (Do not emit wrong E0308 suggestion for closure mismatch)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fe07531 into rust-lang:master Jan 8, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 8, 2023
@clubby789 clubby789 deleted the borrow-mut-self-mut-self-diag branch February 11, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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
5 participants