// found type `()`
if let Some(hir::ItemKind::Impl { items, .. }) = item.map(|i| &i.kind) {
let trait_assoc_item = tcx.associated_item(proj.projection_def_id());
- if let Some(impl_item) = items
- .iter()
- .filter(|item| item.ident == trait_assoc_item.ident)
- .next()
+ if let Some(impl_item) =
+ items.iter().find(|item| item.ident == trait_assoc_item.ident)
{
cause.span = impl_item.span;
cause.code = traits::AssocTypeBound(Box::new(AssocTypeBoundData {
{
if let Some((impl_item, trait_assoc_item)) = trait_assoc_items
.iter()
- .filter(|i| i.def_id == *item_def_id)
- .next()
+ .find(|i| i.def_id == *item_def_id)
.and_then(|trait_assoc_item| {
items
.iter()
- .filter(|i| i.ident == trait_assoc_item.ident)
- .next()
+ .find(|i| i.ident == trait_assoc_item.ident)
.map(|impl_item| (impl_item, trait_assoc_item))
})
{
for missing in &self.missing_named_lifetime_spots {
match missing {
MissingLifetimeSpot::Generics(generics) => {
- let (span, sugg) = if let Some(param) = generics
- .params
- .iter()
- .filter(|p| match p.kind {
+ let (span, sugg) = if let Some(param) =
+ generics.params.iter().find(|p| match p.kind {
hir::GenericParamKind::Type {
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
..
} => false,
_ => true,
- })
- .next()
- {
+ }) {
(param.span.shrink_to_lo(), format!("{}, ", lifetime_ref))
} else {
(generics.span, format!("<{}>", lifetime_ref))
Applicability::MaybeIncorrect,
);
};
- let suggest_new =
- |err: &mut DiagnosticBuilder<'_>, sugg: &str| {
- err.span_label(span, "expected named lifetime parameter");
+ let suggest_new = |err: &mut DiagnosticBuilder<'_>, sugg: &str| {
+ err.span_label(span, "expected named lifetime parameter");
- for missing in self.missing_named_lifetime_spots.iter().rev() {
- let mut introduce_suggestion = vec![];
- let msg;
- let should_break;
- introduce_suggestion.push(match missing {
+ for missing in self.missing_named_lifetime_spots.iter().rev() {
+ let mut introduce_suggestion = vec![];
+ let msg;
+ let should_break;
+ introduce_suggestion.push(match missing {
MissingLifetimeSpot::Generics(generics) => {
msg = "consider introducing a named lifetime parameter".to_string();
should_break = true;
- if let Some(param) = generics.params.iter().filter(|p| match p.kind {
+ if let Some(param) = generics.params.iter().find(|p| match p.kind {
hir::GenericParamKind::Type {
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
..
} => false,
_ => true,
- }).next() {
+ }) {
(param.span.shrink_to_lo(), "'a, ".to_string())
} else {
(generics.span, "<'a>".to_string())
(*span, span_type.suggestion("'a"))
}
});
- for param in params {
- if let Ok(snippet) =
- self.tcx.sess.source_map().span_to_snippet(param.span)
- {
- if snippet.starts_with("&") && !snippet.starts_with("&'") {
- introduce_suggestion
- .push((param.span, format!("&'a {}", &snippet[1..])));
- } else if snippet.starts_with("&'_ ") {
- introduce_suggestion
- .push((param.span, format!("&'a {}", &snippet[4..])));
- }
+ for param in params {
+ if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(param.span)
+ {
+ if snippet.starts_with("&") && !snippet.starts_with("&'") {
+ introduce_suggestion
+ .push((param.span, format!("&'a {}", &snippet[1..])));
+ } else if snippet.starts_with("&'_ ") {
+ introduce_suggestion
+ .push((param.span, format!("&'a {}", &snippet[4..])));
}
}
- introduce_suggestion.push((span, sugg.to_string()));
- err.multipart_suggestion(
- &msg,
- introduce_suggestion,
- Applicability::MaybeIncorrect,
- );
- if should_break {
- break;
- }
}
- };
+ introduce_suggestion.push((span, sugg.to_string()));
+ err.multipart_suggestion(
+ &msg,
+ introduce_suggestion,
+ Applicability::MaybeIncorrect,
+ );
+ if should_break {
+ break;
+ }
+ }
+ };
match (
lifetime_names.len(),