about summary refs log tree commit diff
path: root/tests/ui/unboxed-closures
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2025-07-26 01:15:04 -0500
committerGitHub <noreply@github.com>2025-07-26 01:15:04 -0500
commit9c13f4fb201e31f51ebaf8633ece12e660263008 (patch)
tree31736ef75ed98aaf136f8cdf53cdb67ea7284dc0 /tests/ui/unboxed-closures
parentf32b23204a0efe2fe8383ed4be1a30b56c1bbf94 (diff)
parenta924d44115b632775ef0d2e12382e285953b0c2c (diff)
downloadrust-9c13f4fb201e31f51ebaf8633ece12e660263008.tar.gz
rust-9c13f4fb201e31f51ebaf8633ece12e660263008.zip
Rollup merge of #144089 - Oneirical:uncountable-integer-1, r=jieyouxu
Rehome 35 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`

rust-lang/rust#143902 divided into smaller, easier to review chunks.

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

The URL addition at the end, as well as moving around the auxiliary files and editing the `stderr` files with the new filename, were done using a Python script.

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
Diffstat (limited to 'tests/ui/unboxed-closures')
-rw-r--r--tests/ui/unboxed-closures/fn-traits-overloading-arity-18952.rs58
-rw-r--r--tests/ui/unboxed-closures/unboxed-closure-call-22789.rs10
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/ui/unboxed-closures/fn-traits-overloading-arity-18952.rs b/tests/ui/unboxed-closures/fn-traits-overloading-arity-18952.rs
new file mode 100644
index 00000000000..4e3bc9b671a
--- /dev/null
+++ b/tests/ui/unboxed-closures/fn-traits-overloading-arity-18952.rs
@@ -0,0 +1,58 @@
+// This issue tests fn_traits overloading on arity.
+//@ run-pass
+
+#![feature(fn_traits)]
+#![feature(unboxed_closures)]
+
+struct Foo;
+
+impl Fn<(isize, isize)> for Foo {
+    extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 1, args.1 + 1)
+    }
+}
+
+impl FnMut<(isize, isize)> for Foo {
+    extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 1, args.1 + 1)
+    }
+}
+
+impl FnOnce<(isize, isize)> for Foo {
+    type Output = (isize, isize);
+    extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 1, args.1 + 1)
+    }
+}
+
+impl Fn<(isize, isize, isize)> for Foo {
+    extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 3, args.1 + 3, args.2 + 3)
+    }
+}
+
+impl FnMut<(isize, isize, isize)> for Foo {
+    extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 3, args.1 + 3, args.2 + 3)
+    }
+}
+impl FnOnce<(isize, isize, isize)> for Foo {
+    type Output = (isize, isize, isize);
+    extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output {
+        println!("{:?}", args);
+        (args.0 + 3, args.1 + 3, args.2 + 3)
+    }
+}
+
+fn main() {
+    let foo = Foo;
+    assert_eq!(foo(1, 1), (2, 2));
+    assert_eq!(foo(1, 1, 1), (4, 4, 4));
+}
+
+// https://github.com/rust-lang/rust/issues/18952
diff --git a/tests/ui/unboxed-closures/unboxed-closure-call-22789.rs b/tests/ui/unboxed-closures/unboxed-closure-call-22789.rs
new file mode 100644
index 00000000000..0bc8bed0588
--- /dev/null
+++ b/tests/ui/unboxed-closures/unboxed-closure-call-22789.rs
@@ -0,0 +1,10 @@
+//@ check-pass
+
+#![feature(unboxed_closures, fn_traits)]
+
+fn main() {
+    let k = |x: i32| { x + 1 };
+    Fn::call(&k, (0,));
+}
+
+// https://github.com/rust-lang/rust/issues/22789