avoid temporary vectors
Avoid collecting an interator just to re-iterate immediately. Rather reuse the previous iterator. (clippy::needless_collect)
This commit is contained in:
parent
74ef0c3e40
commit
8462a378f3
2 changed files with 5 additions and 9 deletions
|
@ -72,13 +72,9 @@ impl Path {
|
||||||
) -> ast::Path {
|
) -> ast::Path {
|
||||||
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
|
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
|
||||||
let lt = mk_lifetimes(cx, span, &self.lifetime);
|
let lt = mk_lifetimes(cx, span, &self.lifetime);
|
||||||
let tys: Vec<P<ast::Ty>> =
|
let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));
|
||||||
self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics)).collect();
|
let params =
|
||||||
let params = lt
|
lt.into_iter().map(GenericArg::Lifetime).chain(tys.map(GenericArg::Type)).collect();
|
||||||
.into_iter()
|
|
||||||
.map(GenericArg::Lifetime)
|
|
||||||
.chain(tys.into_iter().map(GenericArg::Type))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
match self.kind {
|
match self.kind {
|
||||||
PathKind::Global => cx.path_all(span, true, idents, params),
|
PathKind::Global => cx.path_all(span, true, idents, params),
|
||||||
|
|
|
@ -2134,7 +2134,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
let new_lt = generics
|
let new_lt = generics
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|(parent_g, g)| {
|
.and_then(|(parent_g, g)| {
|
||||||
let possible: Vec<_> = (b'a'..=b'z').map(|c| format!("'{}", c as char)).collect();
|
let mut possible = (b'a'..=b'z').map(|c| format!("'{}", c as char));
|
||||||
let mut lts_names = g
|
let mut lts_names = g
|
||||||
.params
|
.params
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -2150,7 +2150,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let lts = lts_names.iter().map(|s| -> &str { &*s }).collect::<Vec<_>>();
|
let lts = lts_names.iter().map(|s| -> &str { &*s }).collect::<Vec<_>>();
|
||||||
possible.into_iter().find(|candidate| !lts.contains(&candidate.as_str()))
|
possible.find(|candidate| !lts.contains(&candidate.as_str()))
|
||||||
})
|
})
|
||||||
.unwrap_or("'lt".to_string());
|
.unwrap_or("'lt".to_string());
|
||||||
let add_lt_sugg = generics
|
let add_lt_sugg = generics
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue