From 02f9167f94a06900ee555a5797081a44ebba009e Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 21 Aug 2019 19:56:46 +0200 Subject: Have tidy ensure that we document all `unsafe` blocks in libcore --- src/libcore/array/mod.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libcore/array/mod.rs') diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs index e1ec8b795d0..74a7d062d3f 100644 --- a/src/libcore/array/mod.rs +++ b/src/libcore/array/mod.rs @@ -156,6 +156,7 @@ where fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_ptr() as *const [T; N]; + // SAFETY: ok because we just checked that the length fits unsafe { Ok(&*ptr) } } else { Err(TryFromSliceError(())) @@ -173,6 +174,7 @@ where fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> { if slice.len() == N { let ptr = slice.as_mut_ptr() as *mut [T; N]; + // SAFETY: ok because we just checked that the length fits unsafe { Ok(&mut *ptr) } } else { Err(TryFromSliceError(())) -- cgit 1.4.1-3-g733a5