about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-08-06 21:49:07 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-08-14 17:28:50 +0000
commit51df1dad6c7465395a8ac3e6c31b04468ba347b4 (patch)
tree31dc607d3c89f3c90f274a12928a04284ef511ff /tests
parentec7c02612527d185c379900b613311bc1dcbf7dc (diff)
downloadrust-51df1dad6c7465395a8ac3e6c31b04468ba347b4.tar.gz
rust-51df1dad6c7465395a8ac3e6c31b04468ba347b4.zip
fixed diagnostic
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/explicit-tail-calls/caller-lifetime-presence.rs51
-rw-r--r--tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr32
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs b/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs
new file mode 100644
index 00000000000..2382bc9dd1e
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/caller-lifetime-presence.rs
@@ -0,0 +1,51 @@
+//! Regression test for: https://github.com/rust-lang/rust/issues/144957
+//!
+//! This test ensures that lifetime information is included in diagnostics.
+//!
+//! Specifically, it checks that the `become` call produces an error with lifetimes shown
+//! in both caller and callee signatures.
+//!
+//! If the test fails:
+//! - Lifetimes may be missing (fix the diagnostic), or
+//! - The message format changed (update the test).
+
+#![feature(explicit_tail_calls)]
+#![allow(incomplete_features)]
+
+fn foo<'a>(_: fn(&'a ())) {
+    become bar(dummy);
+    //~^ ERROR mismatched signatures
+    //~| NOTE `become` requires caller and callee to have matching signatures
+    //~| NOTE caller signature: `fn(fn(&'a ()))`
+    //~| NOTE callee signature: `fn(for<'a> fn(&'a ()))`
+}
+
+fn bar(_: fn(&())) {}
+
+fn dummy(_: &()) {}
+
+fn foo_(_: fn(&())) {
+    become bar1(dummy2);
+    //~^ ERROR mismatched signatures
+    //~| NOTE `become` requires caller and callee to have matching signatures
+    //~| NOTE caller signature: `fn(for<'a> fn(&'a ()))`
+    //~| NOTE callee signature: `fn(fn(&'a ()))`
+}
+
+fn bar1<'a>(_: fn(&'a ())) {}
+
+fn dummy2(_: &()) {}
+
+fn foo__(_: fn(&'static ())) {
+    become bar(dummy3);
+    //~^ ERROR mismatched signatures
+    //~| NOTE `become` requires caller and callee to have matching signatures
+    //~| NOTE caller signature: `fn(fn(&'static ()))`
+    //~| NOTE callee signature: `fn(for<'a> fn(&'a ()))`
+}
+
+fn bar2(_: fn(&())) {}
+
+fn dummy3(_: &()) {}
+
+fn main() {}
diff --git a/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr b/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr
new file mode 100644
index 00000000000..2fb981d9682
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/caller-lifetime-presence.stderr
@@ -0,0 +1,32 @@
+error: mismatched signatures
+  --> $DIR/caller-lifetime-presence.rs:16:5
+   |
+LL |     become bar(dummy);
+   |     ^^^^^^^^^^^^^^^^^
+   |
+   = note: `become` requires caller and callee to have matching signatures
+   = note: caller signature: `fn(fn(&'a ()))`
+   = note: callee signature: `fn(for<'a> fn(&'a ()))`
+
+error: mismatched signatures
+  --> $DIR/caller-lifetime-presence.rs:28:5
+   |
+LL |     become bar1(dummy2);
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `become` requires caller and callee to have matching signatures
+   = note: caller signature: `fn(for<'a> fn(&'a ()))`
+   = note: callee signature: `fn(fn(&'a ()))`
+
+error: mismatched signatures
+  --> $DIR/caller-lifetime-presence.rs:40:5
+   |
+LL |     become bar(dummy3);
+   |     ^^^^^^^^^^^^^^^^^^
+   |
+   = note: `become` requires caller and callee to have matching signatures
+   = note: caller signature: `fn(fn(&'static ()))`
+   = note: callee signature: `fn(for<'a> fn(&'a ()))`
+
+error: aborting due to 3 previous errors
+