|
1 | 1 | // Issue 8142: Test that Drop impls cannot be specialized beyond the |
2 | 2 | // predicates attached to the type definition itself. |
3 | | -trait Bound { fn foo(&self) { } } |
4 | | -struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } |
5 | | -struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 } |
6 | | -struct M<'m> { x: &'m i8 } |
7 | | -struct N<'n> { x: &'n i8 } |
8 | | -struct O<To> { x: *const To } |
9 | | -struct P<Tp> { x: *const Tp } |
10 | | -struct Q<Tq> { x: *const Tq } |
11 | | -struct R<Tr> { x: *const Tr } |
12 | | -struct S<Ts:Bound> { x: *const Ts } |
13 | | -struct T<'t,Ts:'t> { x: &'t Ts } |
| 3 | +trait Bound { |
| 4 | + fn foo(&self) {} |
| 5 | +} |
| 6 | +struct K<'l1, 'l2> { |
| 7 | + x: &'l1 i8, |
| 8 | + y: &'l2 u8, |
| 9 | +} |
| 10 | +struct L<'l1, 'l2> { |
| 11 | + x: &'l1 i8, |
| 12 | + y: &'l2 u8, |
| 13 | +} |
| 14 | +struct M<'m> { |
| 15 | + x: &'m i8, |
| 16 | +} |
| 17 | +struct N<'n> { |
| 18 | + x: &'n i8, |
| 19 | +} |
| 20 | +struct O<To> { |
| 21 | + x: *const To, |
| 22 | +} |
| 23 | +struct P<Tp> { |
| 24 | + x: *const Tp, |
| 25 | +} |
| 26 | +struct Q<Tq> { |
| 27 | + x: *const Tq, |
| 28 | +} |
| 29 | +struct R<Tr> { |
| 30 | + x: *const Tr, |
| 31 | +} |
| 32 | +struct S<Ts: Bound> { |
| 33 | + x: *const Ts, |
| 34 | +} |
| 35 | +struct T<'t, Ts: 't> { |
| 36 | + x: &'t Ts, |
| 37 | +} |
14 | 38 | struct U; |
15 | | -struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb } |
16 | | -struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } |
| 39 | +struct V<Tva, Tvb> { |
| 40 | + x: *const Tva, |
| 41 | + y: *const Tvb, |
| 42 | +} |
| 43 | +struct W<'l1, 'l2> { |
| 44 | + x: &'l1 i8, |
| 45 | + y: &'l2 u8, |
| 46 | +} |
17 | 47 | struct X<const Ca: usize>; |
18 | 48 | struct Y<const Ca: usize, const Cb: usize>; |
19 | 49 |
|
20 | | -enum Enum<T> { Variant(T) } |
| 50 | +enum Enum<T> { |
| 51 | + Variant(T), |
| 52 | +} |
21 | 53 | struct TupleStruct<T>(T); |
22 | | -union Union<T: Copy> { f: T } |
| 54 | +union Union<T: Copy> { |
| 55 | + f: T, |
| 56 | +} |
23 | 57 |
|
24 | | -impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT |
| 58 | +impl<'al, 'adds_bnd: 'al> Drop for K<'al, 'adds_bnd> { |
25 | 59 | //~^ ERROR `Drop` impl requires `'adds_bnd: 'al` |
26 | | - fn drop(&mut self) { } } |
27 | | - |
28 | | -impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT |
29 | | - //~^ ERROR `Drop` impl requires `'adds_bnd: 'al` |
30 | | - fn drop(&mut self) { } } |
31 | | - |
32 | | -impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT |
33 | | - |
34 | | -impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT |
35 | | -//~^ ERROR `Drop` impls cannot be specialized |
36 | | - |
37 | | -impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT |
38 | | - |
39 | | -impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT |
40 | | -//~^ ERROR `Drop` impls cannot be specialized |
41 | | - |
42 | | -impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT |
43 | | -//~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
44 | | - |
45 | | -impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT |
46 | | -//~^ ERROR `Drop` impl requires `AddsRBnd: 'rbnd` |
47 | | - |
48 | | -impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT |
49 | | - |
50 | | -impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT |
51 | | - |
52 | | -impl Drop for U { fn drop(&mut self) { } } // ACCEPT |
53 | | - |
54 | | -impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT |
55 | | -//~^ ERROR `Drop` impls cannot be specialized |
56 | | - |
57 | | -impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT |
58 | | -//~^ ERROR `Drop` impls cannot be specialized |
59 | | - |
60 | | -impl Drop for X<3> { fn drop(&mut self) { } } // REJECT |
61 | | -//~^ ERROR `Drop` impls cannot be specialized |
62 | | - |
63 | | -impl<const Ca: usize> Drop for Y<Ca, Ca> { fn drop(&mut self) { } } // REJECT |
64 | | -//~^ ERROR `Drop` impls cannot be specialized |
65 | | - |
66 | | -impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT |
67 | | -//~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
68 | | - |
69 | | -impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT |
70 | | -//~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
71 | | - |
72 | | -impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT |
73 | | -//~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
74 | | - |
75 | | -pub fn main() { } |
| 60 | + fn drop(&mut self) {} |
| 61 | +} |
| 62 | + |
| 63 | +impl<'al, 'adds_bnd> Drop for L<'al, 'adds_bnd> |
| 64 | +//~^ ERROR `Drop` impl requires `'adds_bnd: 'al` |
| 65 | +where |
| 66 | + 'adds_bnd: 'al, |
| 67 | +{ |
| 68 | + fn drop(&mut self) {} |
| 69 | +} |
| 70 | + |
| 71 | +impl<'ml> Drop for M<'ml> { |
| 72 | + fn drop(&mut self) {} |
| 73 | +} |
| 74 | + |
| 75 | +impl Drop for N<'static> { |
| 76 | + //~^ ERROR `Drop` impls cannot be specialized |
| 77 | + fn drop(&mut self) {} |
| 78 | +} |
| 79 | + |
| 80 | +impl<COkNoBound> Drop for O<COkNoBound> { |
| 81 | + fn drop(&mut self) {} |
| 82 | +} |
| 83 | + |
| 84 | +impl Drop for P<i8> { |
| 85 | + //~^ ERROR `Drop` impls cannot be specialized |
| 86 | + fn drop(&mut self) {} |
| 87 | +} |
| 88 | + |
| 89 | +impl<AddsBnd: Bound> Drop for Q<AddsBnd> { |
| 90 | + //~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
| 91 | + fn drop(&mut self) {} |
| 92 | +} |
| 93 | + |
| 94 | +impl<'rbnd, AddsRBnd: 'rbnd> Drop for R<AddsRBnd> { |
| 95 | + fn drop(&mut self) {} |
| 96 | +} |
| 97 | + |
| 98 | +impl<Bs: Bound> Drop for S<Bs> { |
| 99 | + fn drop(&mut self) {} |
| 100 | +} |
| 101 | + |
| 102 | +impl<'t, Bt: 't> Drop for T<'t, Bt> { |
| 103 | + fn drop(&mut self) {} |
| 104 | +} |
| 105 | + |
| 106 | +impl Drop for U { |
| 107 | + fn drop(&mut self) {} |
| 108 | +} |
| 109 | + |
| 110 | +impl<One> Drop for V<One, One> { |
| 111 | + //~^ ERROR `Drop` impls cannot be specialized |
| 112 | + fn drop(&mut self) {} |
| 113 | +} |
| 114 | + |
| 115 | +impl<'lw> Drop for W<'lw, 'lw> { |
| 116 | + //~^ ERROR `Drop` impls cannot be specialized |
| 117 | + fn drop(&mut self) {} |
| 118 | +} |
| 119 | + |
| 120 | +impl Drop for X<3> { |
| 121 | + //~^ ERROR `Drop` impls cannot be specialized |
| 122 | + fn drop(&mut self) {} |
| 123 | +} |
| 124 | + |
| 125 | +impl<const Ca: usize> Drop for Y<Ca, Ca> { |
| 126 | + //~^ ERROR `Drop` impls cannot be specialized |
| 127 | + fn drop(&mut self) {} |
| 128 | +} |
| 129 | + |
| 130 | +impl<AddsBnd: Bound> Drop for Enum<AddsBnd> { |
| 131 | + //~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
| 132 | + fn drop(&mut self) {} |
| 133 | +} |
| 134 | + |
| 135 | +impl<AddsBnd: Bound> Drop for TupleStruct<AddsBnd> { |
| 136 | + //~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
| 137 | + fn drop(&mut self) {} |
| 138 | +} |
| 139 | + |
| 140 | +impl<AddsBnd: Copy + Bound> Drop for Union<AddsBnd> { |
| 141 | + //~^ ERROR `Drop` impl requires `AddsBnd: Bound` |
| 142 | + fn drop(&mut self) {} |
| 143 | +} |
| 144 | + |
| 145 | +pub fn main() {} |
0 commit comments