Fix issue #44731.
Also excludes `impl Trait` from everybody_loops if it appears in the path.
This commit is contained in:
parent
82ae9682ca
commit
16c110f78b
2 changed files with 68 additions and 1 deletions
|
@ -659,10 +659,26 @@ impl ReplaceBodyWithLoop {
|
|||
ast::TyKind::Ptr(ast::MutTy { ty: ref subty, .. }) |
|
||||
ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. }) |
|
||||
ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
|
||||
ast::TyKind::Tup(ref tys) => tys.iter().any(|subty| involves_impl_trait(subty)),
|
||||
ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
|
||||
ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
|
||||
match seg.parameters.as_ref().map(|p| &**p) {
|
||||
None => false,
|
||||
Some(&ast::PathParameters::AngleBracketed(ref data)) =>
|
||||
any_involves_impl_trait(data.types.iter()) ||
|
||||
any_involves_impl_trait(data.bindings.iter().map(|b| &b.ty)),
|
||||
Some(&ast::PathParameters::Parenthesized(ref data)) =>
|
||||
any_involves_impl_trait(data.inputs.iter()) ||
|
||||
any_involves_impl_trait(data.output.iter()),
|
||||
}
|
||||
}),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn any_involves_impl_trait<'a, I: Iterator<Item = &'a P<ast::Ty>>>(mut it: I) -> bool {
|
||||
it.any(|subty| involves_impl_trait(subty))
|
||||
}
|
||||
|
||||
involves_impl_trait(ty)
|
||||
} else {
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue