]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/reject-specialized-drops-8142.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / reject-specialized-drops-8142.rs
CommitLineData
c34b1796
AL
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.
4//
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.
10
11// Issue 8142: Test that Drop impls cannot be specialized beyond the
12// predicates attached to the struct/enum definition itself.
13
c34b1796
AL
14trait Bound { fn foo(&self) { } }
15struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
16struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
17struct M<'m> { x: &'m i8 }
18struct N<'n> { x: &'n i8 }
19struct O<To> { x: *const To }
20struct P<Tp> { x: *const Tp }
21struct Q<Tq> { x: *const Tq }
22struct R<Tr> { x: *const Tr }
23struct S<Ts:Bound> { x: *const Ts }
24struct T<'t,Ts:'t> { x: &'t Ts }
25struct U;
26struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
27struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
28
c34b1796
AL
29impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
30 //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
31 fn drop(&mut self) { } }
32
c34b1796
AL
33impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
34 //~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
35 fn drop(&mut self) { } }
36
c34b1796
AL
37impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT
38
c34b1796 39impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT
e9174d1e
SL
40//~^ ERROR mismatched types
41//~| expected `N<'n>`
42//~| found `N<'static>`
c34b1796 43
c34b1796
AL
44impl<Cok_nobound> Drop for O<Cok_nobound> { fn drop(&mut self) { } } // ACCEPT
45
c34b1796
AL
46impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
47//~^ ERROR Implementations of Drop cannot be specialized
48
c34b1796 49impl<Adds_bnd:Bound> Drop for Q<Adds_bnd> { fn drop(&mut self) { } } // REJECT
54a0048b 50//~^ ERROR The requirement `Adds_bnd: Bound` is added only by the Drop impl.
c34b1796 51
c34b1796
AL
52impl<'rbnd,Adds_rbnd:'rbnd> Drop for R<Adds_rbnd> { fn drop(&mut self) { } } // REJECT
53//~^ ERROR The requirement `Adds_rbnd : 'rbnd` is added only by the Drop impl.
54
c34b1796
AL
55impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT
56
c34b1796
AL
57impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
58
59impl Drop for U { fn drop(&mut self) { } } // ACCEPT
60
c34b1796 61impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
e9174d1e 62//~^ ERROR Implementations of Drop cannot be specialized
c34b1796 63
c34b1796 64impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
e9174d1e 65//~^ ERROR cannot infer an appropriate lifetime
c34b1796
AL
66
67pub fn main() { }