Rollup merge of #122969 - cuviper:borrowck-rposition, r=matthewjasper
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:
commit
c94d229337
@ -4,7 +4,6 @@
|
|||||||
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
|
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
|
||||||
CaptureVarKind, CaptureVarPathUseCause, OnClosureNote,
|
CaptureVarKind, CaptureVarPathUseCause, OnClosureNote,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
|
||||||
use rustc_errors::{Applicability, Diag};
|
use rustc_errors::{Applicability, Diag};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorKind, Namespace};
|
use rustc_hir::def::{CtorKind, Namespace};
|
||||||
@ -226,16 +225,15 @@ pub(super) fn describe_place_with_options(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if autoderef_index.is_none() {
|
if autoderef_index.is_none() {
|
||||||
autoderef_index =
|
autoderef_index = match place.projection.iter().rposition(|elem| {
|
||||||
match place.projection.into_iter().rev().find_position(|elem| {
|
!matches!(
|
||||||
!matches!(
|
elem,
|
||||||
elem,
|
ProjectionElem::Deref | ProjectionElem::Downcast(..)
|
||||||
ProjectionElem::Deref | ProjectionElem::Downcast(..)
|
)
|
||||||
)
|
}) {
|
||||||
}) {
|
Some(index) => Some(index + 1),
|
||||||
Some((index, _)) => Some(place.projection.len() - index),
|
None => Some(0),
|
||||||
None => Some(0),
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if index >= autoderef_index.unwrap() {
|
if index >= autoderef_index.unwrap() {
|
||||||
buf.insert(0, '*');
|
buf.insert(0, '*');
|
||||||
|
Loading…
Reference in New Issue
Block a user