]> git.lizzy.rs Git - rust.git/blob - src/test/ui/reject-specialized-drops-8142.rs
Auto merge of #67000 - spastorino:remove-promoted-from-place, r=oli-obk
[rust.git] / src / test / ui / reject-specialized-drops-8142.rs
1 // Issue 8142: Test that Drop impls cannot be specialized beyond the
2 // predicates attached to the type definition itself.
3
4 trait Bound { fn foo(&self) { } }
5 struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
6 struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
7 struct M<'m> { x: &'m i8 }
8 struct N<'n> { x: &'n i8 }
9 struct O<To> { x: *const To }
10 struct P<Tp> { x: *const Tp }
11 struct Q<Tq> { x: *const Tq }
12 struct R<Tr> { x: *const Tr }
13 struct S<Ts:Bound> { x: *const Ts }
14 struct T<'t,Ts:'t> { x: &'t Ts }
15 struct U;
16 struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
17 struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
18
19 enum Enum<T> { Variant(T) }
20 struct TupleStruct<T>(T);
21 union Union<T: Copy> { f: T }
22
23 impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> {                        // REJECT
24     //~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
25     fn drop(&mut self) { } }
26
27 impl<'al,'adds_bnd>     Drop for L<'al,'adds_bnd> where 'adds_bnd:'al {    // REJECT
28     //~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
29     fn drop(&mut self) { } }
30
31 impl<'ml>               Drop for M<'ml>         { fn drop(&mut self) { } } // ACCEPT
32
33 impl                    Drop for N<'static>     { fn drop(&mut self) { } } // REJECT
34 //~^ ERROR mismatched types
35 //~| expected struct `N<'n>`
36 //~|    found struct `N<'static>`
37
38 impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT
39
40 impl              Drop for P<i8>          { fn drop(&mut self) { } } // REJECT
41 //~^ ERROR `Drop` impls cannot be specialized
42
43 impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
44 //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
45
46 impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT
47 //~^ ERROR `Drop` impl requires `AddsRBnd : 'rbnd`
48
49 impl<Bs:Bound>    Drop for S<Bs>          { fn drop(&mut self) { } } // ACCEPT
50
51 impl<'t,Bt:'t>    Drop for T<'t,Bt>       { fn drop(&mut self) { } } // ACCEPT
52
53 impl              Drop for U              { fn drop(&mut self) { } } // ACCEPT
54
55 impl<One>         Drop for V<One,One>     { fn drop(&mut self) { } } // REJECT
56 //~^ ERROR `Drop` impls cannot be specialized
57
58 impl<'lw>         Drop for W<'lw,'lw>     { fn drop(&mut self) { } } // REJECT
59 //~^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'lw`
60
61 impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT
62 //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
63
64 impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT
65 //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
66
67 impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT
68 //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
69
70 pub fn main() { }