Simplify an iterator search in borrowck diag

Rather than `.into_iter().rev().find_position(...)`, this case can
simply call `.iter().rposition(...)`.
This commit is contained in:
Josh Stone 2024-03-23 17:24:13 -07:00
parent e50ab29471
commit 66f1e14cc3

View File

@ -4,7 +4,6 @@
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
CaptureVarKind, CaptureVarPathUseCause, OnClosureNote,
};
use itertools::Itertools;
use rustc_errors::{Applicability, Diag};
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, Namespace};
@ -226,14 +225,13 @@ pub(super) fn describe_place_with_options(
}
} else {
if autoderef_index.is_none() {
autoderef_index =
match place.projection.into_iter().rev().find_position(|elem| {
autoderef_index = match place.projection.iter().rposition(|elem| {
!matches!(
elem,
ProjectionElem::Deref | ProjectionElem::Downcast(..)
)
}) {
Some((index, _)) => Some(place.projection.len() - index),
Some(index) => Some(index + 1),
None => Some(0),
};
}