/// Pretty-printer for matrices of patterns, example:
/// ++++++++++++++++++++++++++
-/// + _ + .index(&FullRange) +
+/// + _ + [] +
/// ++++++++++++++++++++++++++
/// + true + [First] +
/// ++++++++++++++++++++++++++
// First, check legality of move bindings.
check_legality_of_move_bindings(cx,
arm.guard.is_some(),
- arm.pats.index(&FullRange));
+ &arm.pats[]);
// Second, if there is a guard on each arm, make sure it isn't
// assigning or borrowing anything mutably.
}
// Fourth, check for unreachable arms.
- check_arms(cx, inlined_arms.index(&FullRange), source);
+ check_arms(cx, &inlined_arms[], source);
// Finally, check if the whole match expression is exhaustive.
// Check for empty enum, because is_useful only works on inhabited types.
is_refutable(cx, &*static_inliner.fold_pat((*pat).clone()), |uncovered_pat| {
cx.tcx.sess.span_err(
pat.span,
- format!("refutable pattern in `for` loop binding: \
+ &format!("refutable pattern in `for` loop binding: \
`{}` not covered",
- pat_to_string(uncovered_pat)).index(&FullRange));
+ pat_to_string(uncovered_pat))[]);
});
// Check legality of move bindings.
for pat in pats.iter() {
let v = vec![&**pat];
- match is_useful(cx, &seen, v.index(&FullRange), LeaveOutWitness) {
+ match is_useful(cx, &seen, &v[], LeaveOutWitness) {
NotUseful => {
match source {
ast::MatchSource::IfLetDesugar { .. } => {
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
match is_useful(cx, matrix, &[DUMMY_WILD_PAT], ConstructWitness) {
UsefulWithWitness(pats) => {
- let witness = match pats.index(&FullRange) {
+ let witness = match &pats[] {
[ref witness] => &**witness,
[] => DUMMY_WILD_PAT,
_ => unreachable!()
UsefulWithWitness(pats) => UsefulWithWitness({
let arity = constructor_arity(cx, &c, left_ty);
let mut result = {
- let pat_slice = pats.index(&FullRange);
+ let pat_slice = &pats[];
let subpats: Vec<_> = range(0, arity).map(|i| {
pat_slice.get(i).map_or(DUMMY_WILD_PAT, |p| &**p)
}).collect();
witness: WitnessPreference) -> Usefulness {
let arity = constructor_arity(cx, &ctor, lty);
let matrix = Matrix(m.iter().filter_map(|r| {
- specialize(cx, r.index(&FullRange), &ctor, 0u, arity)
+ specialize(cx, &r[], &ctor, 0u, arity)
}).collect());
match specialize(cx, v, &ctor, 0u, arity) {
- Some(v) => is_useful(cx, &matrix, v.index(&FullRange), witness),
+ Some(v) => is_useful(cx, &matrix, &v[], witness),
None => NotUseful
}
}
/// This computes the arity of a constructor. The arity of a constructor
/// is how many subpattern patterns of that constructor should be expanded to.
///
-/// For instance, a tuple pattern (_, 42u, Some(.index(&FullRange))) has the arity of 3.
+/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
/// A struct pattern's arity is the number of fields it contains, etc.
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> uint {
match ty.sty {
}
};
head.map(|mut head| {
- head.push_all(r.index(&(0..col)));
- head.push_all(r.index(&((col + 1)..)));
+ head.push_all(&r[..col]);
+ head.push_all(&r[col + 1..]);
head
})
}
_ => {
cx.tcx.sess.span_bug(
p.span,
- format!("binding pattern {} is not an \
+ &format!("binding pattern {} is not an \
identifier: {:?}",
p.id,
- p.node).index(&FullRange));
+ p.node)[]);
}
}
}