1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 // Check that item-less traits do not cause dropck to inject extra
15 // region constraints.
17 #![allow(non_camel_case_types)]
19 #![feature(dropck_parametricity)]
23 impl UserDefined for i32 { }
24 impl<'a, T> UserDefined for &'a T { }
26 // e.g., `impl_drop!(Send, D_Send)` expands to:
28 // struct D_Send<T:Send>(T);
29 // impl<T:Send> Drop for D_Send<T> { fn drop(&mut self) { } }
31 macro_rules! impl_drop {
32 ($Bound:ident, $Id:ident) => {
33 struct $Id<T:$Bound>(T);
34 impl <T:$Bound> Drop for $Id<T> {
35 #[unsafe_destructor_blind_to_params]
36 fn drop(&mut self) { }
41 impl_drop!{Send, D_Send}
42 impl_drop!{Sized, D_Sized}
44 // See note below regarding Issue 24895
45 // impl_drop!{Copy, D_Copy}
47 impl_drop!{Sync, D_Sync}
48 impl_drop!{UserDefined, D_UserDefined}
52 // `_d` and `d1` are assigned the *same* lifetime by region inference ...
56 // ... we store a reference to `d1` within `_d` ...
59 // ... a *conservative* dropck will thus complain, because it
60 // thinks Drop of _d could access the already dropped `d1`.
64 fn f_send() { body!(D_Send) }
65 fn f_sized() { body!(D_Sized) }
66 fn f_sync() { body!(D_Sync) }
68 // Issue 24895: Copy: Clone implies `impl<T:Copy> Drop for ...` can
69 // access a user-defined clone() method, which causes this test case
72 // If 24895 is resolved by removing the `Copy: Clone` relationship,
73 // then this definition and the call below should be uncommented. If
74 // it is resolved by deciding to keep the `Copy: Clone` relationship,
75 // then this comment and the associated bits of code can all be
78 // fn f_copy() { body!(D_Copy) }
80 fn f_userdefined() { body!(D_UserDefined) }
85 // See note above regarding Issue 24895.