]> git.proxmox.com Git - rustc.git/blame - src/test/ui/reject-specialized-drops-8142.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / reject-specialized-drops-8142.rs
CommitLineData
c34b1796
AL
1// Issue 8142: Test that Drop impls cannot be specialized beyond the
2// predicates attached to the struct/enum definition itself.
3
c34b1796
AL
4trait Bound { fn foo(&self) { } }
5struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
6struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
7struct M<'m> { x: &'m i8 }
8struct N<'n> { x: &'n i8 }
9struct O<To> { x: *const To }
10struct P<Tp> { x: *const Tp }
11struct Q<Tq> { x: *const Tq }
12struct R<Tr> { x: *const Tr }
13struct S<Ts:Bound> { x: *const Ts }
14struct T<'t,Ts:'t> { x: &'t Ts }
15struct U;
16struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
17struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
18
c34b1796
AL
19impl<'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) { } }
22
c34b1796
AL
23impl<'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) { } }
26
c34b1796
AL
27impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT
28
c34b1796 29impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT
e9174d1e 30//~^ ERROR mismatched types
60c5eb7d
XL
31//~| expected struct `N<'n>`
32//~| found struct `N<'static>`
c34b1796 33
0731742a 34impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT
c34b1796 35
c34b1796
AL
36impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
37//~^ ERROR Implementations of Drop cannot be specialized
38
0731742a
XL
39impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
40//~^ ERROR The requirement `AddsBnd: Bound` is added only by the Drop impl.
c34b1796 41
0731742a
XL
42impl<'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.
c34b1796 44
c34b1796
AL
45impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT
46
c34b1796
AL
47impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
48
49impl Drop for U { fn drop(&mut self) { } } // ACCEPT
50
c34b1796 51impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
e9174d1e 52//~^ ERROR Implementations of Drop cannot be specialized
c34b1796 53
c34b1796 54impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
e74abb32 55//~^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'lw`
c34b1796
AL
56
57pub fn main() { }