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``
This commit is contained in:
commit
c8c225f22f
4 changed files with 74 additions and 0 deletions
|
|
@ -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() {}
|
||||
|
|
@ -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`.
|
||||
|
|
@ -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
tests/ui/traits/solver-cycles/129541-recursive-struct.rs
Normal file
19
tests/ui/traits/solver-cycles/129541-recursive-struct.rs
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue