From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/dropck/reject-specialized-drops-8142.rs | 75 ++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/ui/dropck/reject-specialized-drops-8142.rs (limited to 'tests/ui/dropck/reject-specialized-drops-8142.rs') diff --git a/tests/ui/dropck/reject-specialized-drops-8142.rs b/tests/ui/dropck/reject-specialized-drops-8142.rs new file mode 100644 index 000000000..7a3bbe7cb --- /dev/null +++ b/tests/ui/dropck/reject-specialized-drops-8142.rs @@ -0,0 +1,75 @@ +// Issue 8142: Test that Drop impls cannot be specialized beyond the +// predicates attached to the type definition itself. +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 { x: *const To } +struct P { x: *const Tp } +struct Q { x: *const Tq } +struct R { x: *const Tr } +struct S { x: *const Ts } +struct T<'t,Ts:'t> { x: &'t Ts } +struct U; +struct V { x: *const Tva, y: *const Tvb } +struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 } +struct X; +struct Y; + +enum Enum { Variant(T) } +struct TupleStruct(T); +union Union { f: T } + +impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT + //~^ ERROR `Drop` impl requires `'adds_bnd: 'al` + fn drop(&mut self) { } } + +impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT + //~^ ERROR `Drop` impl requires `'adds_bnd: 'al` + 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 +//~^ ERROR `Drop` impls cannot be specialized + +impl Drop for O { fn drop(&mut self) { } } // ACCEPT + +impl Drop for P { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impls cannot be specialized + +impl Drop for Q { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impl requires `AddsBnd: Bound` + +impl<'rbnd,AddsRBnd:'rbnd> Drop for R { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impl requires `AddsRBnd: 'rbnd` + +impl Drop for S { 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 Drop for V { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impls cannot be specialized + +impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impls cannot be specialized + +impl Drop for X<3> { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impls cannot be specialized + +impl Drop for Y { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impls cannot be specialized + +impl Drop for Enum { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impl requires `AddsBnd: Bound` + +impl Drop for TupleStruct { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impl requires `AddsBnd: Bound` + +impl Drop for Union { fn drop(&mut self) { } } // REJECT +//~^ ERROR `Drop` impl requires `AddsBnd: Bound` + +pub fn main() { } -- cgit v1.2.3