]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/migrations/precise.rs
3 #![deny(rust_2021_incompatible_closure_captures)]
4 //~^ NOTE: the lint level is defined here
10 println
!("{:?} dropped", self.0);
14 struct ConstainsDropField(Foo
, Foo
);
16 // Test that lint is triggered if a path that implements Drop is not captured by move
17 fn test_precise_analysis_drop_paths_not_captured_by_move() {
18 let t
= ConstainsDropField(Foo(10), Foo(20));
21 //~^ ERROR: drop order
22 //~| NOTE: for more information, see
23 //~| HELP: add a dummy let to cause `t` to be fully captured
25 //~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
31 //~^ NOTE: in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
41 // Test precise analysis for the lint works with paths longer than one.
42 fn test_precise_analysis_long_path_missing() {
43 let u
= U(T(S
, S
), T(S
, S
));
46 //~^ ERROR: drop order
47 //~| NOTE: for more information, see
48 //~| HELP: add a dummy let to cause `u` to be fully captured
50 //~^ NOTE: in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.0`
52 //~^ NOTE: in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.0.1`
54 //~^ NOTE: in Rust 2018, this closure captures all of `u`, but in Rust 2021, it will only capture `u.1.0`
59 //~^ NOTE: in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.0` will be dropped here as part of the closure
60 //~| NOTE: in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.0.1` will be dropped here as part of the closure
61 //~| NOTE: in Rust 2018, `u` is dropped here, but in Rust 2021, only `u.1.0` will be dropped here as part of the closure
65 test_precise_analysis_drop_paths_not_captured_by_move();
66 test_precise_analysis_long_path_missing();