Skip to content

Commit 1a061dd

Browse files
committed
Merge pull request #112 from pcwalton/remove-cross-borrowing
Accepted RFC #32: Remove cross-borrowing
2 parents 4d661e7 + 5f46469 commit 1a061dd

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

active/0032-remove-cross-borrowing.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- Start Date: 2014-06-09
2+
- RFC PR #: 112
3+
- Rust Issue #: #10504
4+
5+
# Summary
6+
7+
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.
28+
29+
# Unresolved questions
30+
31+
None.

0 commit comments

Comments
 (0)