Skip to content

Commit fe55c00

Browse files
committed
Add regression test
1 parent aec67e2 commit fe55c00

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub trait Parser<E> {
2+
fn parse(&self) -> E;
3+
}
4+
5+
impl<E, T: Fn() -> E> Parser<E> for T {
6+
fn parse(&self) -> E {
7+
self()
8+
}
9+
}
10+
11+
pub fn recursive_fn<E>() -> impl Parser<E> {
12+
//~^ ERROR: cycle detected
13+
move || recursive_fn().parse()
14+
//~^ ERROR: type annotations needed
15+
//~| ERROR: no method named `parse` found for opaque type
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/recursive-bound-eval.rs:13:28
3+
|
4+
LL | move || recursive_fn().parse()
5+
| ^^^^^ cannot infer type
6+
7+
error[E0599]: no method named `parse` found for opaque type `impl Parser<_>` in the current scope
8+
--> $DIR/recursive-bound-eval.rs:13:28
9+
|
10+
LL | move || recursive_fn().parse()
11+
| ^^^^^ method not found in `impl Parser<_>`
12+
|
13+
= help: items from traits can only be used if the trait is implemented and in scope
14+
help: trait `Parser` which provides `parse` is implemented but not in scope; perhaps you want to import it
15+
|
16+
LL + use Parser;
17+
|
18+
19+
error[E0391]: cycle detected when computing type of opaque `recursive_fn::{opaque#0}`
20+
--> $DIR/recursive-bound-eval.rs:11:29
21+
|
22+
LL | pub fn recursive_fn<E>() -> impl Parser<E> {
23+
| ^^^^^^^^^^^^^^
24+
|
25+
note: ...which requires type-checking `recursive_fn`...
26+
--> $DIR/recursive-bound-eval.rs:13:13
27+
|
28+
LL | move || recursive_fn().parse()
29+
| ^^^^^^^^^^^^^^
30+
= note: ...which requires evaluating trait selection obligation `recursive_fn::{opaque#0}: core::marker::Unpin`...
31+
= note: ...which again requires computing type of opaque `recursive_fn::{opaque#0}`, completing the cycle
32+
note: cycle used when computing type of `recursive_fn::{opaque#0}`
33+
--> $DIR/recursive-bound-eval.rs:11:29
34+
|
35+
LL | pub fn recursive_fn<E>() -> impl Parser<E> {
36+
| ^^^^^^^^^^^^^^
37+
= 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
38+
39+
error: aborting due to 3 previous errors
40+
41+
Some errors have detailed explanations: E0282, E0391, E0599.
42+
For more information about an error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)