3 // Check that item-less traits do not cause dropck to inject extra
6 #![allow(non_camel_case_types)]
8 #![feature(dropck_eyepatch)]
12 impl UserDefined for i32 { }
13 impl<'a, T> UserDefined for &'a T { }
15 // e.g., `impl_drop!(Send, D_Send)` expands to:
17 // struct D_Send<T:Send>(T);
18 // impl<T:Send> Drop for D_Send<T> { fn drop(&mut self) { } }
20 macro_rules! impl_drop {
21 ($Bound:ident, $Id:ident) => {
22 struct $Id<T: $Bound>(#[allow(unused_tuple_struct_fields)] T);
23 unsafe impl <#[may_dangle] T: $Bound> Drop for $Id<T> {
24 fn drop(&mut self) { }
29 impl_drop!{Send, D_Send}
30 impl_drop!{Sized, D_Sized}
32 // See note below regarding Issue 24895
33 // impl_drop!{Copy, D_Copy}
35 impl_drop!{Sync, D_Sync}
36 impl_drop!{UserDefined, D_UserDefined}
40 // `_d` and `d1` are assigned the *same* lifetime by region inference ...
44 // ... we store a reference to `d1` within `_d` ...
47 // ... a *conservative* dropck will thus complain, because it
48 // thinks Drop of _d could access the already dropped `d1`.
52 fn f_send() { body!(D_Send) }
53 fn f_sized() { body!(D_Sized) }
54 fn f_sync() { body!(D_Sync) }
56 // Issue 24895: Copy: Clone implies `impl<T:Copy> Drop for ...` can
57 // access a user-defined clone() method, which causes this test case
60 // If 24895 is resolved by removing the `Copy: Clone` relationship,
61 // then this definition and the call below should be uncommented. If
62 // it is resolved by deciding to keep the `Copy: Clone` relationship,
63 // then this comment and the associated bits of code can all be
66 // fn f_copy() { body!(D_Copy) }
68 fn f_userdefined() { body!(D_UserDefined) }
73 // See note above regarding Issue 24895.