diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 9e100d0a58d17..0b6fb0db1d6f7 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -713,8 +713,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// Disposes of a value. /// -/// While this does call the argument's implementation of [`Drop`][drop], -/// it will not release any borrows, as borrows are based on lexical scope. +/// This does call the argument's implementation of [`Drop`][drop]. /// /// This effectively does nothing for types which implement `Copy`, e.g. /// integers. Such values are copied and _then_ moved into the function, so the @@ -741,32 +740,6 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// drop(v); // explicitly drop the vector /// ``` /// -/// Borrows are based on lexical scope, so this produces an error: -/// -/// ```compile_fail,E0502 -/// let mut v = vec![1, 2, 3]; -/// let x = &v[0]; -/// -/// drop(x); // explicitly drop the reference, but the borrow still exists -/// -/// v.push(4); // error: cannot borrow `v` as mutable because it is also -/// // borrowed as immutable -/// ``` -/// -/// An inner scope is needed to fix this: -/// -/// ``` -/// let mut v = vec![1, 2, 3]; -/// -/// { -/// let x = &v[0]; -/// -/// drop(x); // this is now redundant, as `x` is going out of scope anyway -/// } -/// -/// v.push(4); // no problems -/// ``` -/// /// Since [`RefCell`] enforces the borrow rules at runtime, `drop` can /// release a [`RefCell`] borrow: ///