about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-01-27 09:19:00 +0000
committerbors <bors@rust-lang.org>2019-01-27 09:19:00 +0000
commit01af12008d63a64446a86d995e772f8a539a4202 (patch)
tree484d47cd29e7b81b72e1d0203c711bcc3b427314 /src
parent1484d0d123860dbd79804e9996f3fa5b6f4a6d58 (diff)
parent9c9144fc1bed833663b26219e735c83708ac6821 (diff)
downloadrust-01af12008d63a64446a86d995e772f8a539a4202.tar.gz
rust-01af12008d63a64446a86d995e772f8a539a4202.zip
Auto merge of #57927 - Alexendoo:mem-drop-nll-docs, r=Centril
Remove lexical scope examples from std::mem::drop

The example no longer produces an error in the 2018 edition
Diffstat (limited to 'src')
-rw-r--r--src/libcore/mem.rs29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 9e100d0a58d..0b6fb0db1d6 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -713,8 +713,7 @@ pub fn replace<T>(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<T>(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:
 ///