]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/migrations/precise.rs
1 #![deny(disjoint_capture_drop_reorder)]
2 //~^ NOTE: the lint level is defined here
8 println
!("{:?} dropped", self.0);
12 struct ConstainsDropField(Foo
, Foo
);
15 struct ContainsAndImplsDrop(Foo
);
16 impl Drop
for ContainsAndImplsDrop
{
18 println
!("{:?} dropped", self.0);
22 // Test that even if all paths starting at root variable that implement Drop are captured,
23 // the lint is triggered if the root variable implements drop and isn't captured.
24 fn test_precise_analysis_parent_root_impl_drop_not_captured() {
25 let t
= ContainsAndImplsDrop(Foo(10));
28 //~^ERROR: drop order affected for closure because of `capture_disjoint_fields`
29 //~| NOTE: drop(&(t));
36 // Test that lint is triggered if a path that implements Drop is not captured by move
37 fn test_precise_analysis_drop_paths_not_captured_by_move() {
38 let t
= ConstainsDropField(Foo(10), Foo(20));
41 //~^ERROR: drop order affected for closure because of `capture_disjoint_fields`
42 //~| NOTE: drop(&(t));
59 // Test precise analysis for the lint works with paths longer than one.
60 fn test_precise_analysis_long_path_missing() {
61 let u
= U(T(S
, S
), T(S
, S
));
64 //~^ERROR: drop order affected for closure because of `capture_disjoint_fields`
65 //~| NOTE: drop(&(u));
75 test_precise_analysis_parent_root_impl_drop_not_captured();
76 test_precise_analysis_drop_paths_not_captured_by_move();
77 test_precise_analysis_long_path_missing();