From c547e08ce20516253c781f6fe1eb26a5bfe2ef56 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sat, 7 Jan 2017 13:41:16 -0500 Subject: [PATCH] Improve safety warning on ptr::swap --- src/libcore/ptr.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index e3ca8eca76c5..0aa8e4319ce2 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -74,7 +74,10 @@ pub const fn null_mut() -> *mut T { 0 as *mut T } /// /// # Safety /// -/// This is only unsafe because it accepts a raw pointer. +/// This function copies the memory through the raw pointers passed to it +/// as arguments, which means they will be dereferenced. +/// +/// Ensure that these pointers are valid before calling `swap`. #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn swap(x: *mut T, y: *mut T) {