Modify mutable deref rule for `&mut T`
This indicates that any movable place expression of type &mut T can be dereferenced to yield a mutable place.
Presently the rule only lists variables and fields of variables. However, if a &mut T is contained within a movable Box, it is also valid to deref the &mut T and use the resulting place mutably, even if the Box was immutable. See the following playgrounds:
- https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=4af671f33e513f042e1639f8170d50a6: Demonstrates that it is possible to deref a
Boxvariable - https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=4af671f33e513f042e1639f8170d50a6: Demonstrates that derefing an immutable
Boxvariable (correctly) does not yield a mutable place.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024
I checked something and this might be a bit trickerier. According to [expr.move.movable-place], x.0 is not a movable place (which is correct). However, it can be dereferenced mutably (which the previous wording reflects).
I'm not sure how to reconcile both cases without building a completely new inductive list.
@rustbot author