about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-01-20 09:59:30 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-01-22 10:38:34 +1100
commit37fbd91eb526cc7e246f7c6c97b1deb9e37879ff (patch)
treee3874af4a0897babe8eb9cf1b0c5b3ebdce387f4
parent416399dc1028545ea0ac6d68fb0b5cc5fa97d393 (diff)
downloadrust-37fbd91eb526cc7e246f7c6c97b1deb9e37879ff.tar.gz
rust-37fbd91eb526cc7e246f7c6c97b1deb9e37879ff.zip
Address review comments.
-rw-r--r--compiler/rustc_middle/src/ty/codec.rs2
-rw-r--r--compiler/rustc_middle/src/ty/context.rs13
-rw-r--r--compiler/rustc_query_system/src/dep_graph/serialized.rs1
-rw-r--r--compiler/rustc_serialize/src/json.rs1
-rw-r--r--compiler/rustc_serialize/src/opaque.rs3
5 files changed, 9 insertions, 11 deletions
diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs
index 4cd3b5e7a50..65b91eedf8a 100644
--- a/compiler/rustc_middle/src/ty/codec.rs
+++ b/compiler/rustc_middle/src/ty/codec.rs
@@ -475,7 +475,7 @@ macro_rules! implement_ty_decoder {
                 }
 
                 #[inline]
-                fn read_raw_bytes_into(&mut self, bytes: &mut [u8]) -> () {
+                fn read_raw_bytes_into(&mut self, bytes: &mut [u8]) {
                     self.opaque.read_raw_bytes_into(bytes)
                 }
             }
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index acc115e48a4..3e619b30ea5 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -2792,9 +2792,9 @@ impl<T, R> InternIteratorElement<T, R> for T {
     ) -> Self::Output {
         // This code is hot enough that it's worth specializing for the most
         // common length lists, to avoid the overhead of `SmallVec` creation.
-        // Lengths 0, 1, and 2 typically account for ~95% of cases. We assume
-        // that if the upper and lower bounds from `size_hint` agree they are
-        // correct.
+        // Lengths 0, 1, and 2 typically account for ~95% of cases. If
+        // `size_hint` is incorrect a panic will occur via an `unwrap` or an
+        // `assert`.
         match iter.size_hint() {
             (0, Some(0)) => {
                 assert!(iter.next().is_none());
@@ -2835,9 +2835,10 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
     ) -> Self::Output {
         // This code is hot enough that it's worth specializing for the most
         // common length lists, to avoid the overhead of `SmallVec` creation.
-        // Lengths 0, 1, and 2 typically account for ~95% of cases. We assume
-        // that if the upper and lower bounds from `size_hint` agree they are
-        // correct.
+        // Lengths 0, 1, and 2 typically account for ~95% of cases. If
+        // `size_hint` is incorrect a panic will occur via an `unwrap` or an
+        // `assert`, unless a failure happens first, in which case the result
+        // will be an error anyway.
         Ok(match iter.size_hint() {
             (0, Some(0)) => {
                 assert!(iter.next().is_none());
diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs
index 2fc626a75b3..283eda7c85e 100644
--- a/compiler/rustc_query_system/src/dep_graph/serialized.rs
+++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs
@@ -142,7 +142,6 @@ impl<'a, K: DepKind + Decodable<opaque::Decoder<'a>>> Decodable<opaque::Decoder<
                         let end = edge_list_data.len().try_into().unwrap();
                         let _i: SerializedDepNodeIndex = edge_list_indices.push((start, end));
                         debug_assert_eq!(_i.index(), _index);
-                        ()
                     })
                 })
             });
diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs
index c005db12099..044de8e4e24 100644
--- a/compiler/rustc_serialize/src/json.rs
+++ b/compiler/rustc_serialize/src/json.rs
@@ -2296,7 +2296,6 @@ impl crate::Decoder for Decoder {
         for c in s.iter_mut() {
             *c = self.read_u8();
         }
-        ()
     }
 
     fn read_enum<T, F>(&mut self, f: F) -> T
diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs
index 89ac7834a39..c272c687a7e 100644
--- a/compiler/rustc_serialize/src/opaque.rs
+++ b/compiler/rustc_serialize/src/opaque.rs
@@ -676,11 +676,10 @@ impl<'a> serialize::Decoder for Decoder<'a> {
     }
 
     #[inline]
-    fn read_raw_bytes_into(&mut self, s: &mut [u8]) -> () {
+    fn read_raw_bytes_into(&mut self, s: &mut [u8]) {
         let start = self.position;
         self.position += s.len();
         s.copy_from_slice(&self.data[start..self.position]);
-        ()
     }
 }