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 --- .../optimization/edge_case.rs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/ui/closures/2229_closure_analysis/optimization/edge_case.rs (limited to 'tests/ui/closures/2229_closure_analysis/optimization/edge_case.rs') diff --git a/tests/ui/closures/2229_closure_analysis/optimization/edge_case.rs b/tests/ui/closures/2229_closure_analysis/optimization/edge_case.rs new file mode 100644 index 000000000..e7edc0bbc --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/optimization/edge_case.rs @@ -0,0 +1,34 @@ +// edition:2021 + +#![feature(rustc_attrs)] +#![allow(unused)] +#![allow(dead_code)] + +struct Int(i32); +struct B<'a>(&'a i32); + +const I : Int = Int(0); +const REF_I : &'static Int = &I; + + +struct MyStruct<'a> { + a: &'static Int, + b: B<'a>, +} + +fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static { + let c = #[rustc_capture_analysis] || drop(&m.a.0); + //~^ ERROR: attributes on expressions are experimental + //~| NOTE: see issue #15701 + //~| ERROR: First Pass analysis includes: + //~| ERROR: Min Capture analysis includes: + //~| NOTE: Capturing m[Deref,(0, 0),Deref,(0, 0)] -> ImmBorrow + //~| NOTE: Min Capture m[Deref,(0, 0),Deref] -> ImmBorrow + c +} + +fn main() { + let t = 0; + let s = MyStruct { a: REF_I, b: B(&t) }; + let _ = foo(&s); +} -- cgit v1.2.3