]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs
2 #![deny(rust_2021_incompatible_closure_captures)]
3 //~^ NOTE: the lint level is defined here
5 // Test the two possible cases for automated migartion using rustfix
6 // - Closure contains a block i.e. `|| { .. };`
7 // - Closure contains just an expr `|| ..;`
13 println
!("{:?} dropped", self.0);
17 fn closure_contains_block() {
18 let t
= (Foo(0), Foo(0));
20 //~^ ERROR: drop order
21 //~| NOTE: for more information, see
22 //~| HELP: add a dummy let to cause `t` to be fully captured
24 //~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
29 //~^ NOTE: in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
31 fn closure_doesnt_contain_block() {
32 let t
= (Foo(0), Foo(0));
34 //~^ ERROR: drop order
35 //~| NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
36 //~| NOTE: for more information, see
37 //~| HELP: add a dummy let to cause `t` to be fully captured
41 //~^ NOTE: in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
44 closure_contains_block();
45 closure_doesnt_contain_block();