From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../unboxed-closures-single-word-env.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs (limited to 'tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs') diff --git a/tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs b/tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs new file mode 100644 index 000000000..8ada7494e --- /dev/null +++ b/tests/ui/unboxed-closures/unboxed-closures-single-word-env.rs @@ -0,0 +1,22 @@ +// run-pass +// Ensures that single-word environments work right in unboxed closures. +// These take a different path in codegen. + +fn a isize>(f: F) -> isize { + f(1, 2) +} + +fn b isize>(mut f: F) -> isize { + f(3, 4) +} + +fn c isize>(f: F) -> isize { + f(5, 6) +} + +fn main() { + let z = 10; + assert_eq!(a(move |x: isize, y| x + y + z), 13); + assert_eq!(b(move |x: isize, y| x + y + z), 17); + assert_eq!(c(move |x: isize, y| x + y + z), 21); +} -- cgit v1.2.3