Skip to content

Commit 6df44ea

Browse files
committed
rollup merge of rust-lang#19137: tbu-/pr_refcell_unsafety
2 parents cca33c3 + f9f5c03 commit 6df44ea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/libcore/cell.rs

+3
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ impl<T> RefCell<T> {
258258
/// Consumes the `RefCell`, returning the wrapped value.
259259
#[unstable = "may be renamed, depending on global conventions"]
260260
pub fn unwrap(self) -> T {
261+
// Since this function takes `self` (the `RefCell`) by value, the
262+
// compiler statically verifies that it is not currently borrowed.
263+
// Therefore the following assertion is just a `debug_assert!`.
261264
debug_assert!(self.borrow.get() == UNUSED);
262265
unsafe{self.value.unwrap()}
263266
}

0 commit comments

Comments
 (0)