diff options
| author | Tshepang Mbambo <hopsi@tuta.io> | 2025-08-25 11:29:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-25 11:29:25 +0200 |
| commit | d1d1fb3bb1ff6c8ea38293c4362aa4716d13eafa (patch) | |
| tree | b92935283dc39332d14862c9227eda4b865a507b /tests/ui/recursion | |
| parent | 06608bafbc4a85ca4ba3008b9b18b34e320e6eba (diff) | |
| parent | 721337b92a2ea898a21ea01e420d80e2e33213d2 (diff) | |
Merge pull request #2551 from rust-lang/rustc-pull
Rustc pull update
Diffstat (limited to 'tests/ui/recursion')
| -rw-r--r-- | tests/ui/recursion/infinite-function-recursion-error-8727.rs | 16 | ||||
| -rw-r--r-- | tests/ui/recursion/infinite-function-recursion-error-8727.stderr | 27 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/recursion/infinite-function-recursion-error-8727.rs b/tests/ui/recursion/infinite-function-recursion-error-8727.rs new file mode 100644 index 00000000000..a4037f76109 --- /dev/null +++ b/tests/ui/recursion/infinite-function-recursion-error-8727.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/8727 +// Verify the compiler fails with an error on infinite function +// recursions. + +//@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes + +fn generic<T>() { //~ WARN function cannot return without recursing + generic::<Option<T>>(); +} +//~^^ ERROR reached the recursion limit while instantiating `generic::<Option< + +fn main () { + // Use generic<T> at least once to trigger instantiation. + generic::<i32>(); +} diff --git a/tests/ui/recursion/infinite-function-recursion-error-8727.stderr b/tests/ui/recursion/infinite-function-recursion-error-8727.stderr new file mode 100644 index 00000000000..13d57ecb3b2 --- /dev/null +++ b/tests/ui/recursion/infinite-function-recursion-error-8727.stderr @@ -0,0 +1,27 @@ +warning: function cannot return without recursing + --> $DIR/infinite-function-recursion-error-8727.rs:8:1 + | +LL | fn generic<T>() { + | ^^^^^^^^^^^^^^^ cannot return without recursing +LL | generic::<Option<T>>(); + | ---------------------- recursive call site + | + = help: a `loop` may express intention better if this is on purpose + = note: `#[warn(unconditional_recursion)]` on by default + +error: reached the recursion limit while instantiating `generic::<Option<Option<Option<Option<...>>>>>` + --> $DIR/infinite-function-recursion-error-8727.rs:9:5 + | +LL | generic::<Option<T>>(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: `generic` defined here + --> $DIR/infinite-function-recursion-error-8727.rs:8:1 + | +LL | fn generic<T>() { + | ^^^^^^^^^^^^^^^ + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-function-recursion-error-8727.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console + +error: aborting due to 1 previous error; 1 warning emitted + |
