rustc_resolve: use Iterator
combinators instead of for
loops where applicable
This commit is contained in:
parent
ae87d005bc
commit
6f22dfe4df
1 changed files with 12 additions and 26 deletions
|
@ -1728,13 +1728,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
}
|
||||
|
||||
let normalized_ident = ident.normalize_to_macros_2_0();
|
||||
let mut outer_res = None;
|
||||
for rib in lifetime_rib_iter {
|
||||
if let Some((&outer, _)) = rib.bindings.get_key_value(&normalized_ident) {
|
||||
outer_res = Some(outer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let outer_res = lifetime_rib_iter
|
||||
.find_map(|rib| rib.bindings.get_key_value(&normalized_ident).map(|(&outer, _)| outer));
|
||||
|
||||
self.emit_undeclared_lifetime_error(lifetime, outer_res);
|
||||
self.record_lifetime_res(lifetime.id, LifetimeRes::Error, LifetimeElisionCandidate::Named);
|
||||
|
@ -1801,23 +1796,21 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
}
|
||||
LifetimeRibKind::AnonymousReportError => {
|
||||
if elided {
|
||||
let mut suggestion = None;
|
||||
for rib in self.lifetime_ribs[i..].iter().rev() {
|
||||
let suggestion = self.lifetime_ribs[i..].iter().rev().find_map(|rib| {
|
||||
if let LifetimeRibKind::Generics {
|
||||
span,
|
||||
kind: LifetimeBinderKind::PolyTrait | LifetimeBinderKind::WhereBound,
|
||||
..
|
||||
} = &rib.kind
|
||||
} = rib.kind
|
||||
{
|
||||
suggestion =
|
||||
Some(errors::ElidedAnonymousLivetimeReportErrorSuggestion {
|
||||
lo: span.shrink_to_lo(),
|
||||
hi: lifetime.ident.span.shrink_to_hi(),
|
||||
});
|
||||
break;
|
||||
Some(errors::ElidedAnonymousLivetimeReportErrorSuggestion {
|
||||
lo: span.shrink_to_lo(),
|
||||
hi: lifetime.ident.span.shrink_to_hi(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
// are we trying to use an anonymous lifetime
|
||||
// on a non GAT associated trait type?
|
||||
if !self.in_func_body
|
||||
|
@ -2486,14 +2479,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
/// Determine whether or not a label from the `rib_index`th label rib is reachable.
|
||||
fn is_label_valid_from_rib(&self, rib_index: usize) -> bool {
|
||||
let ribs = &self.label_ribs[rib_index + 1..];
|
||||
|
||||
for rib in ribs {
|
||||
if rib.kind.is_label_barrier() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
ribs.iter().all(|rib| !rib.kind.is_label_barrier())
|
||||
}
|
||||
|
||||
fn resolve_adt(&mut self, item: &'ast Item, generics: &'ast Generics) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue