2015-03-24 04:46:40 -05:00
|
|
|
// Issue 8142: Test that Drop impls cannot be specialized beyond the
|
2020-01-02 18:02:06 -06:00
|
|
|
// predicates attached to the type definition itself.
|
2015-03-24 04:46:40 -05:00
|
|
|
trait Bound { fn foo(&self) { } }
|
|
|
|
struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
|
|
|
|
struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
|
|
|
|
struct M<'m> { x: &'m i8 }
|
|
|
|
struct N<'n> { x: &'n i8 }
|
|
|
|
struct O<To> { x: *const To }
|
|
|
|
struct P<Tp> { x: *const Tp }
|
|
|
|
struct Q<Tq> { x: *const Tq }
|
|
|
|
struct R<Tr> { x: *const Tr }
|
|
|
|
struct S<Ts:Bound> { x: *const Ts }
|
|
|
|
struct T<'t,Ts:'t> { x: &'t Ts }
|
|
|
|
struct U;
|
|
|
|
struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
|
|
|
|
struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
|
2020-11-12 08:39:21 -06:00
|
|
|
struct X<const Ca: usize>;
|
|
|
|
struct Y<const Ca: usize, const Cb: usize>;
|
2015-03-24 04:46:40 -05:00
|
|
|
|
2020-01-02 18:02:06 -06:00
|
|
|
enum Enum<T> { Variant(T) }
|
|
|
|
struct TupleStruct<T>(T);
|
|
|
|
union Union<T: Copy> { f: T }
|
|
|
|
|
2015-03-24 04:46:40 -05:00
|
|
|
impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
|
2020-01-24 14:04:17 -06:00
|
|
|
//~^ ERROR `Drop` impl requires `'adds_bnd: 'al`
|
2015-03-24 04:46:40 -05:00
|
|
|
fn drop(&mut self) { } }
|
|
|
|
|
|
|
|
impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
|
2020-01-24 14:04:17 -06:00
|
|
|
//~^ ERROR `Drop` impl requires `'adds_bnd: 'al`
|
2015-03-24 04:46:40 -05:00
|
|
|
fn drop(&mut self) { } }
|
|
|
|
|
|
|
|
impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT
|
|
|
|
|
|
|
|
impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT
|
2022-03-23 04:06:29 -05:00
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
2015-03-24 04:46:40 -05:00
|
|
|
|
2018-12-16 21:21:47 -06:00
|
|
|
impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT
|
2015-03-24 04:46:40 -05:00
|
|
|
|
|
|
|
impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
|
2020-01-02 18:02:06 -06:00
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
2015-03-24 04:46:40 -05:00
|
|
|
|
2018-12-16 21:21:47 -06:00
|
|
|
impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
|
2020-01-02 18:02:06 -06:00
|
|
|
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
|
2015-03-24 04:46:40 -05:00
|
|
|
|
2018-12-16 21:21:47 -06:00
|
|
|
impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT
|
2020-01-24 14:04:17 -06:00
|
|
|
//~^ ERROR `Drop` impl requires `AddsRBnd: 'rbnd`
|
2015-03-24 04:46:40 -05:00
|
|
|
|
|
|
|
impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT
|
|
|
|
|
|
|
|
impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
|
|
|
|
|
|
|
|
impl Drop for U { fn drop(&mut self) { } } // ACCEPT
|
|
|
|
|
|
|
|
impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
|
2020-01-02 18:02:06 -06:00
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
2015-03-24 04:46:40 -05:00
|
|
|
|
|
|
|
impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
|
2022-03-23 04:06:29 -05:00
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
2015-03-24 04:46:40 -05:00
|
|
|
|
2020-11-12 08:39:21 -06:00
|
|
|
impl Drop for X<3> { fn drop(&mut self) { } } // REJECT
|
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
|
|
|
|
|
|
|
impl<const Ca: usize> Drop for Y<Ca, Ca> { fn drop(&mut self) { } } // REJECT
|
|
|
|
//~^ ERROR `Drop` impls cannot be specialized
|
|
|
|
|
2020-01-02 18:02:06 -06:00
|
|
|
impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT
|
|
|
|
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
|
|
|
|
|
|
|
|
impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT
|
|
|
|
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
|
|
|
|
|
|
|
|
impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT
|
|
|
|
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
|
|
|
|
|
2015-03-24 04:46:40 -05:00
|
|
|
pub fn main() { }
|