Skip to content

Commit 816aee2

Browse files
NadrierilCentril
andcommittedNov 6, 2019
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
1 parent 9531787 commit 816aee2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎src/librustc_mir/hair/pattern/_match.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,9 @@ enum Constructor<'tcx> {
586586
ConstantValue(&'tcx ty::Const<'tcx>, Span),
587587
/// Ranges of literal values (`2..=5` and `2..5`).
588588
ConstantRange(u128, u128, Ty<'tcx>, RangeEnd, Span),
589-
/// Array patterns of length n.
589+
/// Array patterns of length `n`.
590590
FixedLenSlice(u64),
591-
/// Slice patterns. Captures any array constructor of length >= i+j.
591+
/// Slice patterns. Captures any array constructor of `length >= i + j`.
592592
VarLenSlice(u64, u64),
593593
}
594594

@@ -616,8 +616,7 @@ impl<'tcx> std::cmp::PartialEq for Constructor<'tcx> {
616616
impl<'tcx> Constructor<'tcx> {
617617
fn is_slice(&self) -> bool {
618618
match self {
619-
FixedLenSlice { .. } => true,
620-
VarLenSlice { .. } => true,
619+
FixedLenSlice { .. } | VarLenSlice { .. } => true,
621620
_ => false,
622621
}
623622
}
@@ -687,13 +686,13 @@ impl<'tcx> Constructor<'tcx> {
687686

688687
// For each used ctor, subtract from the current set of constructors.
689688
// Naming: we remove the "neg" constructors from the "pos" ones.
690-
// Remember, VarLenSlice(i, j) covers the union of FixedLenSlice from
691-
// i+j to infinity.
689+
// Remember, `VarLenSlice(i, j)` covers the union of `FixedLenSlice` from
690+
// `i + j` to infinity.
692691
for neg_ctor in other_ctors {
693692
remaining_ctors = remaining_ctors
694693
.into_iter()
695694
.flat_map(|pos_ctor| -> SmallVec<[Constructor<'tcx>; 1]> {
696-
// Compute pos_ctor \ neg_ctor
695+
// Compute `pos_ctor \ neg_ctor`.
697696
match (&pos_ctor, neg_ctor) {
698697
(&FixedLenSlice(pos_len), &VarLenSlice(neg_prefix, neg_suffix)) => {
699698
let neg_len = neg_prefix + neg_suffix;
@@ -722,7 +721,7 @@ impl<'tcx> Constructor<'tcx> {
722721
} else {
723722
(pos_len..neg_len)
724723
.map(FixedLenSlice)
725-
// We know neg_len + 1 >= pos_len >= pos_suffix
724+
// We know that `neg_len + 1 >= pos_len >= pos_suffix`.
726725
.chain(Some(VarLenSlice(
727726
neg_len + 1 - pos_suffix,
728727
pos_suffix,
@@ -2081,7 +2080,7 @@ fn split_grouped_constructors<'p, 'tcx>(
20812080
}
20822081

20832082
// For diagnostics, we keep the prefix and suffix lengths separate, so in the case
2084-
// where `max_fixed_len+1` is the largest, we adapt `max_prefix_len` accordingly,
2083+
// where `max_fixed_len + 1` is the largest, we adapt `max_prefix_len` accordingly,
20852084
// so that `L = max_prefix_len + max_suffix_len`.
20862085
if max_fixed_len + 1 >= max_prefix_len + max_suffix_len {
20872086
// The subtraction can't overflow thanks to the above check.

0 commit comments

Comments
 (0)
Please sign in to comment.