1
Fork 0

Do not suggest impl traits as type arguments

This commit is contained in:
Yuki Okushi 2021-06-16 06:32:22 +09:00
parent 3354a44d2f
commit 14e92d7116
No known key found for this signature in database
GPG key ID: DABA5B072961C18A
7 changed files with 71 additions and 16 deletions

View file

@ -198,6 +198,21 @@ impl<'tcx> Generics {
_ => bug!("expected const parameter, but found another generic parameter"),
}
}
/// Returns `true` if `params` has `impl Trait`.
pub fn has_impl_trait(&'tcx self) -> bool {
self.params.iter().any(|param| {
matches!(
param.kind,
ty::GenericParamDefKind::Type {
synthetic: Some(
hir::SyntheticTyParamKind::ImplTrait | hir::SyntheticTyParamKind::FromAttr,
),
..
}
)
})
}
}
/// Bounds on generics.