diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-11 06:49:05 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-06-11 08:08:25 +0000 |
| commit | fe55c0091db4654ad0185831aa3dd110e5e6cd73 (patch) | |
| tree | 3c2f31a4f568fefeef6c0e86230d8d88252760c2 | |
| parent | aec67e238d366c4c41373b272f19dd79ff5ec0f0 (diff) | |
| download | rust-fe55c0091db4654ad0185831aa3dd110e5e6cd73.tar.gz rust-fe55c0091db4654ad0185831aa3dd110e5e6cd73.zip | |
Add regression test
| -rw-r--r-- | tests/ui/impl-trait/recursive-bound-eval.rs | 18 | ||||
| -rw-r--r-- | tests/ui/impl-trait/recursive-bound-eval.stderr | 42 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/recursive-bound-eval.rs b/tests/ui/impl-trait/recursive-bound-eval.rs new file mode 100644 index 00000000000..f992cb3071a --- /dev/null +++ b/tests/ui/impl-trait/recursive-bound-eval.rs @@ -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() {} diff --git a/tests/ui/impl-trait/recursive-bound-eval.stderr b/tests/ui/impl-trait/recursive-bound-eval.stderr new file mode 100644 index 00000000000..c7283380234 --- /dev/null +++ b/tests/ui/impl-trait/recursive-bound-eval.stderr @@ -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`. |
