diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-11-26 15:32:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-26 15:32:18 +0100 |
| commit | c8c225f22fe8ab2cba0a144768ff9fc121ccb435 (patch) | |
| tree | c7bac5ab3a884396d545d6a9b547f326b1cc505c | |
| parent | a06532e6391fea733790e4f8c8ce20f89775fb61 (diff) | |
| parent | b77d8fa12946472176094725055a07f9d0ce3440 (diff) | |
| download | rust-c8c225f22fe8ab2cba0a144768ff9fc121ccb435.tar.gz rust-c8c225f22fe8ab2cba0a144768ff9fc121ccb435.zip | |
Rollup merge of #133467 - Enselic:recurse-tests, r=lcnr
tests: Add recursive associated type bound regression tests Add regression tests for https://github.com/rust-lang/rust/issues/129541 as requested in https://github.com/rust-lang/rust/issues/129541#issuecomment-2498514488. Closes #129541 r? ``@lcnr``
4 files changed, 74 insertions, 0 deletions
diff --git a/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs new file mode 100644 index 00000000000..197207dfb4b --- /dev/null +++ b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.rs @@ -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() {} diff --git a/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr new file mode 100644 index 00000000000..50dcea0bfac --- /dev/null +++ b/tests/ui/traits/solver-cycles/129541-recursive-enum-and-array-impl.stderr @@ -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`. diff --git a/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs b/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs new file mode 100644 index 00000000000..defb39aae06 --- /dev/null +++ b/tests/ui/traits/solver-cycles/129541-recursive-struct-and-array-impl.rs @@ -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() {} diff --git a/tests/ui/traits/solver-cycles/129541-recursive-struct.rs b/tests/ui/traits/solver-cycles/129541-recursive-struct.rs new file mode 100644 index 00000000000..d4339dd54d6 --- /dev/null +++ b/tests/ui/traits/solver-cycles/129541-recursive-struct.rs @@ -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() {} |
