about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHanif Bin Ariffin <hanif.ariffin.4326@gmail.com>2020-04-25 19:46:53 -0400
committerHanif Bin Ariffin <hanif.ariffin.4326@gmail.com>2020-06-13 15:06:22 -0400
commit9e1e989f7cfbc9bb35511acdeb51b3122bf717a2 (patch)
tree2a23ae5d89d53e48630c7a42186453f312dd7ce4
parent9e8b42c02bfa348b024ad07652e860b125345acf (diff)
downloadrust-9e1e989f7cfbc9bb35511acdeb51b3122bf717a2.tar.gz
rust-9e1e989f7cfbc9bb35511acdeb51b3122bf717a2.zip
Document unsafety in partial_insertion_sort
We already implicitly (or explicitly??) do the bound checking for the indexing.
-rw-r--r--src/libcore/slice/sort.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcore/slice/sort.rs b/src/libcore/slice/sort.rs
index 0177c5a9ffd..937995e2fe0 100644
--- a/src/libcore/slice/sort.rs
+++ b/src/libcore/slice/sort.rs
@@ -131,6 +131,8 @@ where
     let mut i = 1;
 
     for _ in 0..MAX_STEPS {
+        // SAFETY: We already explicitly done the bound checking with `i<len`
+        // All our indexing following that is only in the range {0 <= index < len}
         unsafe {
             // Find the next pair of adjacent out-of-order elements.
             while i < len && !is_less(v.get_unchecked(i), v.get_unchecked(i - 1)) {