-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add recursive associated type bound regression tests
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/associated_type_bound/129541-recursive-enum-and-array-impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/traits/associated_type_bound/129541-recursive-enum-and-array-impl.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
23 changes: 23 additions & 0 deletions
23
tests/ui/traits/associated_type_bound/129541-recursive-struct-and-array-impl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
tests/ui/traits/associated_type_bound/129541-recursive-struct.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |