]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/issue-90465.rs
Rollup merge of #107177 - thanatos:fix-doc-errant-light-theme, r=notriddle
[rust.git] / tests / ui / closures / 2229_closure_analysis / issue-90465.rs
1 // run-rustfix
2
3 #![deny(rust_2021_incompatible_closure_captures)]
4 //~^ NOTE lint level is defined here
5
6 fn main() {
7     struct Foo(u32);
8     impl Drop for Foo {
9         fn drop(&mut self) {
10             println!("dropped {}", self.0);
11         }
12     }
13
14     let f0 = Foo(0);
15     let f1 = Foo(1);
16
17     let c0 = move || {
18         //~^ ERROR changes to closure capture in Rust 2021 will affect drop order
19         //~| NOTE for more information
20         let _ = f0;
21         //~^ NOTE in Rust 2018, this causes the closure to capture `f0`, but in Rust 2021, it has no effect
22     };
23
24     let c1 = move || {
25         let _ = &f1;
26     };
27
28     println!("dropping 0");
29     drop(c0);
30     println!("dropping 1");
31     drop(c1);
32     println!("dropped all");
33 }
34 //~^ NOTE in Rust 2018, `f0` is dropped here along with the closure, but in Rust 2021 `f0` is not part of the closure