1
Fork 0

don't restuct references just to reborrow

This commit is contained in:
Matthias Krüger 2022-12-18 17:01:58 +01:00
parent 35a99eef32
commit a108d55ce6
22 changed files with 41 additions and 42 deletions

View file

@ -551,16 +551,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
//
// FIXME(#29623) we could use PatKind::Range to rule
// things out here, in some cases.
(
&TestKind::SwitchInt { switch_ty: _, ref options },
&PatKind::Constant { ref value },
) if is_switch_ty(match_pair.pattern.ty) => {
(TestKind::SwitchInt { switch_ty: _, options }, PatKind::Constant { value })
if is_switch_ty(match_pair.pattern.ty) =>
{
let index = options.get_index_of(value).unwrap();
self.candidate_without_match_pair(match_pair_index, candidate);
Some(index)
}
(&TestKind::SwitchInt { switch_ty: _, ref options }, &PatKind::Range(ref range)) => {
(TestKind::SwitchInt { switch_ty: _, options }, PatKind::Range(range)) => {
let not_contained =
self.values_not_contained_in_range(&*range, options).unwrap_or(false);
@ -578,7 +577,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(
&TestKind::Len { len: test_len, op: BinOp::Eq },
&PatKind::Slice { ref prefix, ref slice, ref suffix },
PatKind::Slice { prefix, slice, suffix },
) => {
let pat_len = (prefix.len() + suffix.len()) as u64;
match (test_len.cmp(&pat_len), slice) {
@ -615,7 +614,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(
&TestKind::Len { len: test_len, op: BinOp::Ge },
&PatKind::Slice { ref prefix, ref slice, ref suffix },
PatKind::Slice { prefix, slice, suffix },
) => {
// the test is `$actual_len >= test_len`
let pat_len = (prefix.len() + suffix.len()) as u64;
@ -651,7 +650,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}
(&TestKind::Range(ref test), &PatKind::Range(ref pat)) => {
(TestKind::Range(test), PatKind::Range(pat)) => {
use std::cmp::Ordering::*;
if test == pat {
@ -678,7 +677,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
no_overlap
}
(&TestKind::Range(ref range), &PatKind::Constant { value }) => {
(TestKind::Range(range), &PatKind::Constant { value }) => {
if let Some(false) = self.const_range_contains(&*range, value) {
// `value` is not contained in the testing range,
// so `value` can be matched only if this test fails.