1
Fork 0

generic_arg_contains_target: ignore closures

This commit is contained in:
lcnr 2022-05-26 12:26:30 +02:00
parent 69d575e58d
commit 681736a6b2
4 changed files with 22 additions and 26 deletions

View file

@ -700,8 +700,14 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
match inner.unpack() {
GenericArgKind::Lifetime(_) => {}
GenericArgKind::Type(ty) => {
if matches!(ty.kind(), ty::Opaque(..)) {
// Opaque types can't be named by the user right now
if matches!(ty.kind(), ty::Opaque(..) | ty::Closure(..) | ty::Generator(..)) {
// Opaque types can't be named by the user right now.
//
// Both the generic arguments of closures and generators can
// also not be named. We may want to only look into the closure
// signature in case it has no captures, as that can be represented
// using `fn(T) -> R`.
// FIXME(type_alias_impl_trait): These opaque types
// can actually be named, so it would make sense to
// adjust this case and add a test for it.