diff options
Diffstat (limited to 'tests/ui/recursion')
| -rw-r--r-- | tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs | 33 | ||||
| -rw-r--r-- | tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr | 17 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs new file mode 100644 index 00000000000..0875d385ddc --- /dev/null +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs @@ -0,0 +1,33 @@ +//@ build-fail +//@ compile-flags: -Copt-level=0 + +fn main() { + rec(Empty); +} + +struct Empty; + +impl Iterator for Empty { + type Item = (); + fn next<'a>(&'a mut self) -> core::option::Option<()> { + None + } +} + +fn identity<T>(x: T) -> T { + x +} + +fn rec<T>(mut it: T) +where + T: Iterator, +{ + if () == () { + T::count(it); + } else { + rec(identity(&mut it)) + //~^ ERROR reached the recursion limit while instantiating + } +} + +// https://github.com/rust-lang/rust/issues/67552 diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr new file mode 100644 index 00000000000..fe005984fab --- /dev/null +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr @@ -0,0 +1,17 @@ +error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` + --> $DIR/recursive-impl-trait-iterator-by-ref-67552.rs:28:9 + | +LL | rec(identity(&mut it)) + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `rec` defined here + --> $DIR/recursive-impl-trait-iterator-by-ref-67552.rs:21:1 + | +LL | / fn rec<T>(mut it: T) +LL | | where +LL | | T: Iterator, + | |________________^ + = note: the full type name has been written to '$TEST_BUILD_DIR/recursive-impl-trait-iterator-by-ref-67552.long-type.txt' + +error: aborting due to 1 previous error + |
