Skip to content

Commit

Permalink
Merge pull request rust-lang#112 from pcwalton/remove-cross-borrowing
Browse files Browse the repository at this point in the history
Accepted RFC rust-lang#32: Remove cross-borrowing
  • Loading branch information
pcwalton committed Jun 25, 2014
2 parents 4d661e7 + 5f46469 commit 1a061dd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions active/0032-remove-cross-borrowing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
- Start Date: 2014-06-09
- RFC PR #: 112
- Rust Issue #: #10504

# Summary

Remove the coercion from `Box<T>` to `&mut T` from the language.

# Motivation

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.

# Detailed design

The coercion between `Box<T>` and `&mut T` should be removed.

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.

# Drawbacks

Borrowing from `Box<T>` to `&mut T` may be convenient.

# Alternatives

An alternative is to remove `&T` coercions as well, but this was decided against as they are convenient.

The impact of not doing this is that the coercion will remain.

# Unresolved questions

None.

0 comments on commit 1a061dd

Please sign in to comment.