3 // Ensures that destructors are run for expressions of the form "let _ = e;"
4 // where `e` is a type which requires a destructor.
8 struct Bar { x: isize }
10 enum FooBar { _Foo(Foo), _Bar(usize) }
12 static mut NUM_DROPS: usize = 0;
16 unsafe { NUM_DROPS += 1; }
21 unsafe { NUM_DROPS += 1; }
26 unsafe { NUM_DROPS += 1; }
29 impl Drop for FooBar {
31 unsafe { NUM_DROPS += 1; }
36 assert_eq!(unsafe { NUM_DROPS }, 0);
38 assert_eq!(unsafe { NUM_DROPS }, 1);
39 { let _x = Bar { x: 21 }; }
40 assert_eq!(unsafe { NUM_DROPS }, 2);
42 assert_eq!(unsafe { NUM_DROPS }, 3);
43 { let _x = FooBar::_Foo(Foo); }
44 assert_eq!(unsafe { NUM_DROPS }, 5);
45 { let _x = FooBar::_Bar(42); }
46 assert_eq!(unsafe { NUM_DROPS }, 6);
49 assert_eq!(unsafe { NUM_DROPS }, 7);
50 { let _ = Bar { x: 21 }; }
51 assert_eq!(unsafe { NUM_DROPS }, 8);
53 assert_eq!(unsafe { NUM_DROPS }, 9);
54 { let _ = FooBar::_Foo(Foo); }
55 assert_eq!(unsafe { NUM_DROPS }, 11);
56 { let _ = FooBar::_Bar(42); }
57 assert_eq!(unsafe { NUM_DROPS }, 12);