You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the coercion from `Box<T>` to `&mut T` from the language.
8
+
9
+
# Motivation
10
+
11
+
Currently, the coercion between `Box<T>` to `&mut T` can be a hazard because it can lead to surprising mutation where it was not expected.
12
+
13
+
# Detailed design
14
+
15
+
The coercion between `Box<T>` and `&mut T` should be removed.
16
+
17
+
Note that methods that take `&mut self` can still be called on values of type `Box<T>` without any special referencing or dereferencing. That is because the semantics of auto-deref and auto-ref conspire to make it work: the types unify after one autoderef followed by one autoref.
18
+
19
+
# Drawbacks
20
+
21
+
Borrowing from `Box<T>` to `&mut T` may be convenient.
22
+
23
+
# Alternatives
24
+
25
+
An alternative is to remove `&T` coercions as well, but this was decided against as they are convenient.
26
+
27
+
The impact of not doing this is that the coercion will remain.
0 commit comments