From ea9d2fb85cedcc7e32ab3ada3f539ad5cf974b53 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 22 May 2022 16:13:25 +0900 Subject: [PATCH] Add regression test for #91949 --- .../traits/issue-91949-hangs-on-recursion.rs | 30 +++++++++++++++++++ .../issue-91949-hangs-on-recursion.stderr | 25 ++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/test/ui/traits/issue-91949-hangs-on-recursion.rs create mode 100644 src/test/ui/traits/issue-91949-hangs-on-recursion.stderr diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.rs b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs new file mode 100644 index 0000000000000..cf2218fe52292 --- /dev/null +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.rs @@ -0,0 +1,30 @@ +// build-fail +// error-pattern: overflow evaluating the requirement `(): Sized` +// error-pattern: function cannot return without recursing + +// Regression test for #91949. +// This hanged *forever* on 1.56, fixed by #90423. + +#![recursion_limit = "256"] + +struct Wrapped(T); + +struct IteratorOfWrapped>(I); + +impl> Iterator for IteratorOfWrapped { + type Item = Wrapped; + fn next(&mut self) -> Option> { + self.0.next().map(Wrapped) + } +} + +fn recurse(elements: T) -> Vec +where + T: Iterator, +{ + recurse(IteratorOfWrapped(elements).map(|t| t.0)) +} + +fn main() { + recurse(std::iter::empty()); +} diff --git a/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr new file mode 100644 index 0000000000000..6c04616344f54 --- /dev/null +++ b/src/test/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -0,0 +1,25 @@ +warning: function cannot return without recursing + --> $DIR/issue-91949-hangs-on-recursion.rs:21:1 + | +LL | / fn recurse(elements: T) -> Vec +LL | | where +LL | | T: Iterator, +LL | | { +LL | | recurse(IteratorOfWrapped(elements).map(|t| t.0)) + | | ------------------------------------------------- recursive call site +LL | | } + | |_^ cannot return without recursing + | + = note: `#[warn(unconditional_recursion)]` on by default + = help: a `loop` may express intention better if this is on purpose + +error[E0275]: overflow evaluating the requirement `(): Sized` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) + = note: required because of the requirements on the impl of `Iterator` for `std::iter::Empty<()>` + = note: 171 redundant requirements hidden + = note: required because of the requirements on the impl of `Iterator` for `IteratorOfWrapped<(), Map>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>, [closure@$DIR/issue-91949-hangs-on-recursion.rs:25:45: 25:52]>>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0275`.