as *mut _
does not cause by-mut
place evaluation, causing an error stating DerefMut
is not implemented, but it is
#86262
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Given the code:
The current output is:
Ideally, this should just work1. Uncommenting the commented line to add an explicit mutable reborrow allows the code to work as intended. But even if it can't work, the error is clearly very unhelpful, as the issue isn't the lack of
DerefMut
, but that the compiler selected a sharedDeref
evaluation of the place.@rustbot modify labels +C-bug +D-incorrect
Footnotes
Importantly, just work and produce a pointer with valid
mut
provenance. It would be technically correct but misleading to allow&mut T as *mut T
behind a shared reference to behave like&mut T as *const T as *mut T
. The actually useful behavior is for the fact thatas *mut
is a by-mut
use of thethis.slot
place to flow back into the selection of whether to evaluate thethis.slot
place by-ref (viaDeref
) or by-mut (viaDerefMut
) the same way other by-mut
place usage does. ↩The text was updated successfully, but these errors were encountered: