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

tests: Add recursive associated type bound regression tests #133467

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Regression test for #129541
//~^ ERROR cycle detected when computing layout of `<[Hello] as Normalize>::Assoc` [E0391]

trait Bound {}
trait Normalize {
type Assoc;
}

impl<T: Bound> Normalize for T {
type Assoc = T;
}

impl<T: Bound> Normalize for [T] {
type Assoc = T;
}

impl Bound for Hello {}
enum Hello {
Variant(<[Hello] as Normalize>::Assoc),
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error[E0391]: cycle detected when computing layout of `<[Hello] as Normalize>::Assoc`
|
= note: ...which requires computing layout of `Hello`...
= note: ...which again requires computing layout of `<[Hello] as Normalize>::Assoc`, completing the cycle
= note: cycle used when computing layout of `Hello`
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Regression test for #129541

//@ check-pass

trait Bound {}
trait Normalize {
type Assoc;
}

impl<T: Bound> Normalize for T {
type Assoc = T;
}

impl<T: Bound> Normalize for [T] {
type Assoc = T;
}

impl Bound for Hello {}
struct Hello {
a: <[Hello] as Normalize>::Assoc,
}

fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/traits/solver-cycles/129541-recursive-struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Regression test for #129541

//@ check-pass

trait Bound {}
trait Normalize {
type Assoc;
}

impl<T: Bound> Normalize for [T] {
type Assoc = T;
}

impl Bound for Hello {}
struct Hello {
a: <[Hello] as Normalize>::Assoc,
}

fn main() {}
Loading