]> git.lizzy.rs Git - rust.git/commitdiff
Apply suggestions from code review
authorNadrieril Feneanar <Nadrieril@users.noreply.github.com>
Wed, 6 Nov 2019 14:51:24 +0000 (14:51 +0000)
committerNadrieril <nadrieril+git@gmail.com>
Wed, 6 Nov 2019 15:09:03 +0000 (15:09 +0000)
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
src/librustc_mir/hair/pattern/_match.rs

index 8d7e605f7c9aa70179a9702be474dbaec58a5e7d..47f8c699e396e410380d272f6bfd45b3bef61a5c 100644 (file)
@@ -586,9 +586,9 @@ enum Constructor<'tcx> {
     ConstantValue(&'tcx ty::Const<'tcx>, Span),
     /// Ranges of literal values (`2..=5` and `2..5`).
     ConstantRange(u128, u128, Ty<'tcx>, RangeEnd, Span),
-    /// Array patterns of length n.
+    /// Array patterns of length `n`.
     FixedLenSlice(u64),
-    /// Slice patterns. Captures any array constructor of length >= i+j.
+    /// Slice patterns. Captures any array constructor of `length >= i + j`.
     VarLenSlice(u64, u64),
 }
 
@@ -616,8 +616,7 @@ fn eq(&self, other: &Self) -> bool {
 impl<'tcx> Constructor<'tcx> {
     fn is_slice(&self) -> bool {
         match self {
-            FixedLenSlice { .. } => true,
-            VarLenSlice { .. } => true,
+            FixedLenSlice { .. } | VarLenSlice { .. } => true,
             _ => false,
         }
     }
@@ -687,13 +686,13 @@ fn subtract_ctors(
 
                 // For each used ctor, subtract from the current set of constructors.
                 // Naming: we remove the "neg" constructors from the "pos" ones.
-                // Remember, VarLenSlice(i, j) covers the union of FixedLenSlice from
-                // i+j to infinity.
+                // Remember, `VarLenSlice(i, j)` covers the union of `FixedLenSlice` from
+                // `i + j` to infinity.
                 for neg_ctor in other_ctors {
                     remaining_ctors = remaining_ctors
                         .into_iter()
                         .flat_map(|pos_ctor| -> SmallVec<[Constructor<'tcx>; 1]> {
-                            // Compute pos_ctor \ neg_ctor
+                            // Compute `pos_ctor \ neg_ctor`.
                             match (&pos_ctor, neg_ctor) {
                                 (&FixedLenSlice(pos_len), &VarLenSlice(neg_prefix, neg_suffix)) => {
                                     let neg_len = neg_prefix + neg_suffix;
@@ -722,7 +721,7 @@ fn subtract_ctors(
                                     } else {
                                         (pos_len..neg_len)
                                             .map(FixedLenSlice)
-                                            // We know neg_len + 1 >= pos_len >= pos_suffix
+                                            // We know that `neg_len + 1 >= pos_len >= pos_suffix`.
                                             .chain(Some(VarLenSlice(
                                                 neg_len + 1 - pos_suffix,
                                                 pos_suffix,
@@ -2081,7 +2080,7 @@ fn range_borders(r: IntRange<'_>) -> impl Iterator<Item = Border> {
                 }
 
                 // For diagnostics, we keep the prefix and suffix lengths separate, so in the case
-                // where `max_fixed_len+1` is the largest, we adapt `max_prefix_len` accordingly,
+                // where `max_fixed_len + 1` is the largest, we adapt `max_prefix_len` accordingly,
                 // so that `L = max_prefix_len + max_suffix_len`.
                 if max_fixed_len + 1 >= max_prefix_len + max_suffix_len {
                     // The subtraction can't overflow thanks to the above check.