Suggest dereferencing non-lval mutable reference on assignment#94639
Suggest dereferencing non-lval mutable reference on assignment#94639bors merged 3 commits intorust-lang:masterfrom
Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? rust-lang/compiler |
There was a problem hiding this comment.
I'm a bit concerned this statement is easy to miss. Is it possible we can move this method to somewhere in the diagnostics code? Or perhaps naming this method so that it includes some mention of this being for diagnostics only.
There was a problem hiding this comment.
Do we know why we lost this message? (It seems like it is correct unlike the one in the previous commit so I'm surprised it's missing.)
There was a problem hiding this comment.
i think it's bc i added must_apply_modulo_regions when checking if the type implements the trait, instead of may_apply, and the fact that we have an infer var on the lhs. i'll see if it causes too many false errors here.
|
@rustbot author |
58316f3 to
0af2014
Compare
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
0af2014 to
b03a154
Compare
There was a problem hiding this comment.
This is kinda a regression, but not actually... &isize doesn't have a +=. Perhaps we could suggest changing the ref to ref mut, but that seems out of scope for this PR.
wesleywiser
left a comment
There was a problem hiding this comment.
r=me with or without nit. Nice work! 💯
There was a problem hiding this comment.
nit: "piece of" just reads a bit awkwardly to me. Maybe "consider dereferencing here to assign to the mutably borrowed memory"?
b03a154 to
d50d3fc
Compare
|
@bors r=wesleywiser |
|
📌 Commit d50d3fc has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#94639 (Suggest dereferencing non-lval mutable reference on assignment) - rust-lang#95979 (update coherence docs, fix generator + opaque type ICE) - rust-lang#96378 (Mention traits and types involved in unstable trait upcasting) - rust-lang#96917 (Make HashMap fall back to RtlGenRandom if BCryptGenRandom fails) - rust-lang#97101 (Add tracking issue for ExitCode::exit_process) - rust-lang#97123 (Clean fix for rust-lang#96223) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| // Suppressing this diagnostic, we'll properly print it in `check_expr_assign` | ||
| return None; |
There was a problem hiding this comment.
@compiler-errors For future reference, adding a delay_span_bug here might be a good idea to protect from miscompilations in the face of refactors.
There was a problem hiding this comment.
shoot, yeah. i can add one in a follow-up.
There was a problem hiding this comment.
Actually, this just suppresses a suggestion, not the error itself. And the other case I actually did suppress a real error, I downgraded it to a delayed bug. See: https://github.com/rust-lang/rust/pull/94639/files#diff-c46757032f463a1170b40e5c41d569ce058668cfe259774fb8a7936e3fdd82f4R57
DerefMutFixes #46276
Fixes #93980