Skip to content

[beta] backports and stage0 bump #126453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add regression test
(cherry picked from commit fe55c00)
  • Loading branch information
oli-obk authored and cuviper committed Jun 14, 2024
commit 11495decd53fe5a11f376475e92c75df97ea8cbb
18 changes: 18 additions & 0 deletions tests/ui/impl-trait/recursive-bound-eval.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pub trait Parser<E> {
fn parse(&self) -> E;
}

impl<E, T: Fn() -> E> Parser<E> for T {
fn parse(&self) -> E {
self()
}
}

pub fn recursive_fn<E>() -> impl Parser<E> {
//~^ ERROR: cycle detected
move || recursive_fn().parse()
//~^ ERROR: type annotations needed
//~| ERROR: no method named `parse` found for opaque type
}

fn main() {}
42 changes: 42 additions & 0 deletions tests/ui/impl-trait/recursive-bound-eval.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
error[E0282]: type annotations needed
--> $DIR/recursive-bound-eval.rs:13:28
|
LL | move || recursive_fn().parse()
| ^^^^^ cannot infer type

error[E0599]: no method named `parse` found for opaque type `impl Parser<_>` in the current scope
--> $DIR/recursive-bound-eval.rs:13:28
|
LL | move || recursive_fn().parse()
| ^^^^^ method not found in `impl Parser<_>`
|
= help: items from traits can only be used if the trait is implemented and in scope
help: trait `Parser` which provides `parse` is implemented but not in scope; perhaps you want to import it
|
LL + use Parser;
|

error[E0391]: cycle detected when computing type of opaque `recursive_fn::{opaque#0}`
--> $DIR/recursive-bound-eval.rs:11:29
|
LL | pub fn recursive_fn<E>() -> impl Parser<E> {
| ^^^^^^^^^^^^^^
|
note: ...which requires type-checking `recursive_fn`...
--> $DIR/recursive-bound-eval.rs:13:13
|
LL | move || recursive_fn().parse()
| ^^^^^^^^^^^^^^
= note: ...which requires evaluating trait selection obligation `recursive_fn::{opaque#0}: core::marker::Unpin`...
= note: ...which again requires computing type of opaque `recursive_fn::{opaque#0}`, completing the cycle
note: cycle used when computing type of `recursive_fn::{opaque#0}`
--> $DIR/recursive-bound-eval.rs:11:29
|
LL | pub fn recursive_fn<E>() -> impl Parser<E> {
| ^^^^^^^^^^^^^^
= 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 3 previous errors

Some errors have detailed explanations: E0282, E0391, E0599.
For more information about an error, try `rustc --explain E0282`.