From f5f11e11978a57f25c27b670d2e8b2b001fc9d01 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 1 Mar 2024 08:47:31 +0000 Subject: [PATCH] Add regression test --- .../hidden_behind_struct_field3.rs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs new file mode 100644 index 00000000000..366767929e4 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs @@ -0,0 +1,28 @@ +//! This test demonstrates a bug where we accidentally +//! detected opaque types in struct fields, but only if nested +//! in projections of another opaque type. +//@ check-pass + +#![feature(impl_trait_in_assoc_type)] + +struct Bar; + +trait Trait: Sized { + type Assoc2; + type Assoc; + fn foo() -> Self::Assoc; +} + +impl Trait for Bar { + type Assoc2 = impl std::fmt::Debug; + type Assoc = impl Iterator; + fn foo() -> Self::Assoc { + vec![Foo { field: () }].into_iter() + } +} + +struct Foo { + field: ::Assoc2, +} + +fn main() {}