Skip to content

Commit c8c225f

Browse files
Rollup merge of rust-lang#133467 - Enselic:recurse-tests, r=lcnr
tests: Add recursive associated type bound regression tests Add regression tests for rust-lang#129541 as requested in rust-lang#129541 (comment). Closes rust-lang#129541 r? ``@lcnr``
2 parents a06532e + b77d8fa commit c8c225f

4 files changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for #129541
2+
//~^ ERROR cycle detected when computing layout of `<[Hello] as Normalize>::Assoc` [E0391]
3+
4+
trait Bound {}
5+
trait Normalize {
6+
type Assoc;
7+
}
8+
9+
impl<T: Bound> Normalize for T {
10+
type Assoc = T;
11+
}
12+
13+
impl<T: Bound> Normalize for [T] {
14+
type Assoc = T;
15+
}
16+
17+
impl Bound for Hello {}
18+
enum Hello {
19+
Variant(<[Hello] as Normalize>::Assoc),
20+
}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error[E0391]: cycle detected when computing layout of `<[Hello] as Normalize>::Assoc`
2+
|
3+
= note: ...which requires computing layout of `Hello`...
4+
= note: ...which again requires computing layout of `<[Hello] as Normalize>::Assoc`, completing the cycle
5+
= note: cycle used when computing layout of `Hello`
6+
= 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
7+
8+
error: aborting due to 1 previous error
9+
10+
For more information about this error, try `rustc --explain E0391`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Regression test for #129541
2+
3+
//@ check-pass
4+
5+
trait Bound {}
6+
trait Normalize {
7+
type Assoc;
8+
}
9+
10+
impl<T: Bound> Normalize for T {
11+
type Assoc = T;
12+
}
13+
14+
impl<T: Bound> Normalize for [T] {
15+
type Assoc = T;
16+
}
17+
18+
impl Bound for Hello {}
19+
struct Hello {
20+
a: <[Hello] as Normalize>::Assoc,
21+
}
22+
23+
fn main() {}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for #129541
2+
3+
//@ check-pass
4+
5+
trait Bound {}
6+
trait Normalize {
7+
type Assoc;
8+
}
9+
10+
impl<T: Bound> Normalize for [T] {
11+
type Assoc = T;
12+
}
13+
14+
impl Bound for Hello {}
15+
struct Hello {
16+
a: <[Hello] as Normalize>::Assoc,
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)