1 // Issue 8142: Test that Drop impls cannot be specialized beyond the
2 // predicates attached to the struct/enum definition itself.
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 }
16 struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
17 struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
19 impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
20 //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
21 fn drop(&mut self) { } }
23 impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
24 //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
25 fn drop(&mut self) { } }
27 impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT
29 impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT
30 //~^ ERROR mismatched types
31 //~| expected type `N<'n>`
32 //~| found type `N<'static>`
34 impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT
36 impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
37 //~^ ERROR Implementations of Drop cannot be specialized
39 impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
40 //~^ ERROR The requirement `AddsBnd: Bound` is added only by the Drop impl.
42 impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT
43 //~^ ERROR The requirement `AddsRBnd : 'rbnd` is added only by the Drop impl.
45 impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT
47 impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
49 impl Drop for U { fn drop(&mut self) { } } // ACCEPT
51 impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
52 //~^ ERROR Implementations of Drop cannot be specialized
54 impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
55 //~^ ERROR cannot infer an appropriate lifetime