Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 1, 2024
1 parent 6cbf092 commit f5f11e1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ui/type-alias-impl-trait/hidden_behind_struct_field3.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit f5f11e1

Please sign in to comment.