-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve compile error for borrowing mut while missing Sized trait bound #93078
Comments
okay..l realized the real reason is that I implies |
Oh lol, I think this is because of autoref. It's trying to take Wonder how much work it is to make autoref during method dispatch to skip taking |
well, I think you are right. It's my thoughtlessness. |
@Niiiiiil I think this is still worthwhile to keep open as an issue because of the confusing error message! |
This came up on URLO in the context of an extension trait, and I'd like to point out how unhelpful the error is:
It is a bit tricky though, as there are at least three possible suggestions:
The last solution is the most correct in my opinion (but can only be applied if that implementation is local). Finally, this variation: fn mute(self: &mut Self) {
self.modify();
} Does give a suggestion: help: consider making the binding mutable
|
11 | fn mute(mut self: &mut Self) {
| +++ Even though it's not the ideal suggestion. Let me know if I should file a separate bug for @rustbot label +D-confusing +D-terse +D-newcomer-roadblock |
…-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
Given the following code:
The current output is:
Ideally the output should look like:
add
Sized
trait bound and the code compiles successfully:rust version: rustc 1.58.0 (02072b4 2022-01-11)
The text was updated successfully, but these errors were encountered: