@@ -713,8 +713,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
713
713
714
714
/// Disposes of a value.
715
715
///
716
- /// While this does call the argument's implementation of [`Drop`][drop],
717
- /// it will not release any borrows, as borrows are based on lexical scope.
716
+ /// This does call the argument's implementation of [`Drop`][drop].
718
717
///
719
718
/// This effectively does nothing for types which implement `Copy`, e.g.
720
719
/// 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 {
741
740
/// drop(v); // explicitly drop the vector
742
741
/// ```
743
742
///
744
- /// Borrows are based on lexical scope, so this produces an error:
745
- ///
746
- /// ```compile_fail,E0502
747
- /// let mut v = vec![1, 2, 3];
748
- /// let x = &v[0];
749
- ///
750
- /// drop(x); // explicitly drop the reference, but the borrow still exists
751
- ///
752
- /// v.push(4); // error: cannot borrow `v` as mutable because it is also
753
- /// // borrowed as immutable
754
- /// ```
755
- ///
756
- /// An inner scope is needed to fix this:
757
- ///
758
- /// ```
759
- /// let mut v = vec![1, 2, 3];
760
- ///
761
- /// {
762
- /// let x = &v[0];
763
- ///
764
- /// drop(x); // this is now redundant, as `x` is going out of scope anyway
765
- /// }
766
- ///
767
- /// v.push(4); // no problems
768
- /// ```
769
- ///
770
743
/// Since [`RefCell`] enforces the borrow rules at runtime, `drop` can
771
744
/// release a [`RefCell`] borrow:
772
745
///
0 commit comments