forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#59459 - JohnTitor:add-tests, r=Centril
Add some tests close rust-lang#52977 It seems that there are no tests for this issue, so I opened this PR. off-topic: I noticed [this test](https://github.com/rust-lang/rust/blob/master/src/test/ui/existential_types/nested_existential_types.rs)'s indents are bad, could I include commit to fix this, or should I separate? r? @oli-obk
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/test/ui/existential_types/existential-types-with-cycle-error.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,12 @@ | ||
#![feature(existential_type)] | ||
|
||
existential type Foo: Fn() -> Foo; | ||
//~^ ERROR: cycle detected when processing `Foo` | ||
|
||
fn crash(x: Foo) -> Foo { | ||
x | ||
} | ||
|
||
fn main() { | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/test/ui/existential_types/existential-types-with-cycle-error.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,30 @@ | ||
error[E0391]: cycle detected when processing `Foo` | ||
--> $DIR/existential-types-with-cycle-error.rs:3:1 | ||
| | ||
LL | existential type Foo: Fn() -> Foo; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires processing `crash`... | ||
--> $DIR/existential-types-with-cycle-error.rs:6:25 | ||
| | ||
LL | fn crash(x: Foo) -> Foo { | ||
| _________________________^ | ||
LL | | x | ||
LL | | } | ||
| |_^ | ||
= note: ...which again requires processing `Foo`, completing the cycle | ||
note: cycle used when collecting item types in top-level module | ||
--> $DIR/existential-types-with-cycle-error.rs:1:1 | ||
| | ||
LL | / #![feature(existential_type)] | ||
LL | | | ||
LL | | existential type Foo: Fn() -> Foo; | ||
LL | | | ||
... | | ||
LL | | | ||
LL | | } | ||
| |_^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |
16 changes: 16 additions & 0 deletions
16
src/test/ui/existential_types/existential-types-with-cycle-error2.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,16 @@ | ||
#![feature(existential_type)] | ||
|
||
pub trait Bar<T> { | ||
type Item; | ||
} | ||
|
||
existential type Foo: Bar<Foo, Item = Foo>; | ||
//~^ ERROR: cycle detected when processing `Foo` | ||
|
||
fn crash(x: Foo) -> Foo { | ||
x | ||
} | ||
|
||
fn main() { | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/test/ui/existential_types/existential-types-with-cycle-error2.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,30 @@ | ||
error[E0391]: cycle detected when processing `Foo` | ||
--> $DIR/existential-types-with-cycle-error2.rs:7:1 | ||
| | ||
LL | existential type Foo: Bar<Foo, Item = Foo>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: ...which requires processing `crash`... | ||
--> $DIR/existential-types-with-cycle-error2.rs:10:25 | ||
| | ||
LL | fn crash(x: Foo) -> Foo { | ||
| _________________________^ | ||
LL | | x | ||
LL | | } | ||
| |_^ | ||
= note: ...which again requires processing `Foo`, completing the cycle | ||
note: cycle used when collecting item types in top-level module | ||
--> $DIR/existential-types-with-cycle-error2.rs:1:1 | ||
| | ||
LL | / #![feature(existential_type)] | ||
LL | | | ||
LL | | pub trait Bar<T> { | ||
LL | | type Item; | ||
... | | ||
LL | | | ||
LL | | } | ||
| |_^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0391`. |