about summary refs log tree commit diff
path: root/tests/ui/recursion
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2025-08-20 05:01:50 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2025-08-20 05:01:50 +0000
commit8d09fb5e6d330b2e32bb98b89fb8a3fadd2bfd48 (patch)
tree8b927cdee8253f3df663c2931a1c6bc8fc980eb2 /tests/ui/recursion
parent49329f0d8a2a79e363150f9b40778a0751ba22e8 (diff)
parentf605b57042ffeb320d7ae44490113a827139b766 (diff)
downloadrust-8d09fb5e6d330b2e32bb98b89fb8a3fadd2bfd48.tar.gz
rust-8d09fb5e6d330b2e32bb98b89fb8a3fadd2bfd48.zip
Merge ref 'f605b57042ff' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: f605b57042ffeb320d7ae44490113a827139b766
Filtered ref: c69d2743ed4676c4529ebb60b258f6c1273c9145

This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'tests/ui/recursion')
-rw-r--r--tests/ui/recursion/infinite-function-recursion-error-8727.rs16
-rw-r--r--tests/ui/recursion/infinite-function-recursion-error-8727.stderr27
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
+