Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the correct logic for nested impl trait in assoc types #121838

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add regression test
  • Loading branch information
oli-obk committed Mar 1, 2024
commit f5f11e11978a57f25c27b670d2e8b2b001fc9d01
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() {}