]> git.lizzy.rs Git - rust.git/commitdiff
The drop_ref test does not require implementing the Drop trait.
authorTheemathas Chirananthavat <theemathas@gmail.com>
Fri, 30 Dec 2016 02:28:49 +0000 (18:28 -0800)
committerTheemathas Chirananthavat <theemathas@gmail.com>
Fri, 6 Jan 2017 01:41:01 +0000 (17:41 -0800)
tests/compile-fail/drop_ref.rs

index 8454a471513dfe1b8585c5ca2ea9ec6682ace32c..76d7d9ca21b5b12592fb971c109d9924fb89ae9e 100644 (file)
@@ -6,26 +6,25 @@
 
 use std::mem::drop;
 
-struct DroppableStruct;
-impl Drop for DroppableStruct { fn drop(&mut self) {} }
+struct SomeStruct;
 
 fn main() {
-    drop(&DroppableStruct); //~ERROR call to `std::mem::drop` with a reference argument
+    drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
 
-    let mut owned = DroppableStruct;
+    let mut owned = SomeStruct;
     drop(&owned); //~ERROR call to `std::mem::drop` with a reference argument
     drop(&&owned); //~ERROR call to `std::mem::drop` with a reference argument
     drop(&mut owned); //~ERROR call to `std::mem::drop` with a reference argument
     drop(owned); //OK
 
-    let reference1 = &DroppableStruct;
+    let reference1 = &SomeStruct;
     drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
     drop(&*reference1); //~ERROR call to `std::mem::drop` with a reference argument
 
-    let reference2 = &mut DroppableStruct;
+    let reference2 = &mut SomeStruct;
     drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
 
-    let ref reference3 = DroppableStruct;
+    let ref reference3 = SomeStruct;
     drop(reference3); //~ERROR call to `std::mem::drop` with a reference argument
 }
 
@@ -38,6 +37,6 @@ fn test_generic_fn<T>(val: T) {
 #[allow(dead_code)]
 fn test_similarly_named_function() {
     fn drop<T>(_val: T) {}
-    drop(&DroppableStruct); //OK; call to unrelated function which happens to have the same name
-    std::mem::drop(&DroppableStruct); //~ERROR call to `std::mem::drop` with a reference argument
+    drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name
+    std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
 }