diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-03-01 08:47:31 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-03-01 08:47:31 +0000 |
| commit | f5f11e11978a57f25c27b670d2e8b2b001fc9d01 (patch) | |
| tree | 620ca5c1c1574de59e418c3fe06004908d317a37 | |
| parent | 6cbf0926d54c80ea6d15df333be9281f65bbeb36 (diff) | |
| download | rust-f5f11e11978a57f25c27b670d2e8b2b001fc9d01.tar.gz rust-f5f11e11978a57f25c27b670d2e8b2b001fc9d01.zip | |
Add regression test
| -rw-r--r-- | tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs | 28 |
1 files changed, 28 insertions, 0 deletions
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<Item = Foo>; + fn foo() -> Self::Assoc { + vec![Foo { field: () }].into_iter() + } +} + +struct Foo { + field: <Bar as Trait>::Assoc2, +} + +fn main() {} |
