+++ /dev/null
-struct Bar(u16); // ZSTs are tested separately
-
-static mut DROP_COUNT: usize = 0;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- assert_eq!(self.0 as usize, unsafe { DROP_COUNT }); // tests whether we are called at a valid address
- unsafe { DROP_COUNT += 1; }
- }
-}
-
-fn main() {
- let b = [Bar(0), Bar(1), Bar(2), Bar(3)];
- assert_eq!(unsafe { DROP_COUNT }, 0);
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-
- // check empty case
- let b : [Bar; 0] = [];
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-}
+++ /dev/null
-trait Foo {}
-
-struct Bar;
-
-impl Foo for Bar {}
-
-static mut DROP_COUNT: usize = 0;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- unsafe { DROP_COUNT += 1; }
- }
-}
-
-fn main() {
- let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
- assert_eq!(unsafe { DROP_COUNT }, 0);
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-}
+++ /dev/null
-struct Bar;
-
-static mut DROP_COUNT: usize = 0;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- unsafe { DROP_COUNT += 1; }
- }
-}
-
-fn main() {
- let b = [Bar, Bar, Bar, Bar];
- assert_eq!(unsafe { DROP_COUNT }, 0);
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-
- // check empty case
- let b : [Bar; 0] = [];
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-}
+++ /dev/null
-struct Bar;
-
-static mut DROP_COUNT: usize = 0;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- unsafe { DROP_COUNT += 1; }
- }
-}
-
-fn main() {
- let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice();
- assert_eq!(unsafe { DROP_COUNT }, 0);
- drop(b);
- assert_eq!(unsafe { DROP_COUNT }, 4);
-}
+++ /dev/null
-trait Foo {}
-
-struct Bar;
-
-static mut DROP_CALLED: bool = false;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- unsafe { DROP_CALLED = true; }
- }
-}
-
-impl Foo for Bar {}
-
-fn main() {
- let b: Box<dyn Foo> = Box::new(Bar);
- assert!(unsafe { !DROP_CALLED });
- drop(b);
- assert!(unsafe { DROP_CALLED });
-}
+++ /dev/null
-trait Foo {}
-
-struct Bar;
-
-static mut DROP_CALLED: bool = false;
-
-impl Drop for Bar {
- fn drop(&mut self) {
- unsafe { DROP_CALLED = true; }
- }
-}
-
-impl Foo for Bar {}
-
-use std::rc::Rc;
-
-fn main() {
- let b: Rc<dyn Foo> = Rc::new(Bar);
- assert!(unsafe { !DROP_CALLED });
- drop(b);
- assert!(unsafe { DROP_CALLED });
-}
--- /dev/null
+struct Bar(u16); // ZSTs are tested separately
+
+static mut DROP_COUNT: usize = 0;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ assert_eq!(self.0 as usize, unsafe { DROP_COUNT }); // tests whether we are called at a valid address
+ unsafe { DROP_COUNT += 1; }
+ }
+}
+
+fn main() {
+ let b = [Bar(0), Bar(1), Bar(2), Bar(3)];
+ assert_eq!(unsafe { DROP_COUNT }, 0);
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+
+ // check empty case
+ let b : [Bar; 0] = [];
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+}
--- /dev/null
+trait Foo {}
+
+struct Bar;
+
+impl Foo for Bar {}
+
+static mut DROP_COUNT: usize = 0;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ unsafe { DROP_COUNT += 1; }
+ }
+}
+
+fn main() {
+ let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
+ assert_eq!(unsafe { DROP_COUNT }, 0);
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+}
--- /dev/null
+struct Bar;
+
+static mut DROP_COUNT: usize = 0;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ unsafe { DROP_COUNT += 1; }
+ }
+}
+
+fn main() {
+ let b = [Bar, Bar, Bar, Bar];
+ assert_eq!(unsafe { DROP_COUNT }, 0);
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+
+ // check empty case
+ let b : [Bar; 0] = [];
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+}
--- /dev/null
+struct Bar;
+
+static mut DROP_COUNT: usize = 0;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ unsafe { DROP_COUNT += 1; }
+ }
+}
+
+fn main() {
+ let b: Box<[Bar]> = vec![Bar, Bar, Bar, Bar].into_boxed_slice();
+ assert_eq!(unsafe { DROP_COUNT }, 0);
+ drop(b);
+ assert_eq!(unsafe { DROP_COUNT }, 4);
+}
--- /dev/null
+trait Foo {}
+
+struct Bar;
+
+static mut DROP_CALLED: bool = false;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ unsafe { DROP_CALLED = true; }
+ }
+}
+
+impl Foo for Bar {}
+
+fn main() {
+ let b: Box<dyn Foo> = Box::new(Bar);
+ assert!(unsafe { !DROP_CALLED });
+ drop(b);
+ assert!(unsafe { DROP_CALLED });
+}
--- /dev/null
+trait Foo {}
+
+struct Bar;
+
+static mut DROP_CALLED: bool = false;
+
+impl Drop for Bar {
+ fn drop(&mut self) {
+ unsafe { DROP_CALLED = true; }
+ }
+}
+
+impl Foo for Bar {}
+
+use std::rc::Rc;
+
+fn main() {
+ let b: Rc<dyn Foo> = Rc::new(Bar);
+ assert!(unsafe { !DROP_CALLED });
+ drop(b);
+ assert!(unsafe { DROP_CALLED });
+}