From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../2229_closure_analysis/run_pass/by_value.rs | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/ui/closures/2229_closure_analysis/run_pass/by_value.rs (limited to 'tests/ui/closures/2229_closure_analysis/run_pass/by_value.rs') diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/by_value.rs b/tests/ui/closures/2229_closure_analysis/run_pass/by_value.rs new file mode 100644 index 000000000..f8752fe1c --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/run_pass/by_value.rs @@ -0,0 +1,26 @@ +// edition:2021 +// run-pass + +// Test that ByValue captures compile successfully especially when the captures are +// dereferenced within the closure. + +#[derive(Debug, Default)] +struct SomeLargeType; +struct MuchLargerType([SomeLargeType; 32]); + +fn big_box() { + let s = MuchLargerType(Default::default()); + let b = Box::new(s); + let t = (b, 10); + + let c = || { + let p = t.0.0; + println!("{} {:?}", t.1, p); + }; + + c(); +} + +fn main() { + big_box(); +} -- cgit v1.2.3