forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
266 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
tests/ui/dropck/constrained_by_assoc_type_equality_and_self_ty.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
trait Trait { | ||
type Assoc; | ||
} | ||
|
||
struct Foo<T: Trait, U: ?Sized>(T, U); | ||
|
||
impl<T: Trait<Assoc = U>, U: ?Sized> Drop for Foo<T, U> { | ||
//~^ ERROR: `Drop` impl requires `<T as Trait>::Assoc == U` | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
10 changes: 5 additions & 5 deletions
10
...constrained_by_assoc_type_equality.stderr → ...by_assoc_type_equality_and_self_ty.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,145 @@ | ||
// 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<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 } | ||
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 } | ||
struct V<Tva, Tvb> { | ||
x: *const Tva, | ||
y: *const Tvb, | ||
} | ||
struct W<'l1, 'l2> { | ||
x: &'l1 i8, | ||
y: &'l2 u8, | ||
} | ||
struct X<const Ca: usize>; | ||
struct Y<const Ca: usize, const Cb: usize>; | ||
|
||
enum Enum<T> { Variant(T) } | ||
enum Enum<T> { | ||
Variant(T), | ||
} | ||
struct TupleStruct<T>(T); | ||
union Union<T: Copy> { f: T } | ||
union Union<T: Copy> { | ||
f: T, | ||
} | ||
|
||
impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT | ||
impl<'al, 'adds_bnd: 'al> Drop for K<'al, 'adds_bnd> { | ||
//~^ 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<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT | ||
|
||
impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
|
||
impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT | ||
//~^ ERROR `Drop` impl requires `AddsBnd: Bound` | ||
|
||
impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT | ||
//~^ ERROR `Drop` impl requires `AddsRBnd: 'rbnd` | ||
|
||
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 | ||
//~^ 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<const Ca: usize> Drop for Y<Ca, Ca> { fn drop(&mut self) { } } // REJECT | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
|
||
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` | ||
|
||
pub fn main() { } | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'al, 'adds_bnd> Drop for L<'al, 'adds_bnd> | ||
//~^ ERROR `Drop` impl requires `'adds_bnd: 'al` | ||
where | ||
'adds_bnd: 'al, | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'ml> Drop for M<'ml> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl Drop for N<'static> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<COkNoBound> Drop for O<COkNoBound> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl Drop for P<i8> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<AddsBnd: Bound> Drop for Q<AddsBnd> { | ||
//~^ ERROR `Drop` impl requires `AddsBnd: Bound` | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'rbnd, AddsRBnd: 'rbnd> Drop for R<AddsRBnd> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<Bs: Bound> Drop for S<Bs> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'t, Bt: 't> Drop for T<'t, Bt> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl Drop for U { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<One> Drop for V<One, One> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'lw> Drop for W<'lw, 'lw> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl Drop for X<3> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<const Ca: usize> Drop for Y<Ca, Ca> { | ||
//~^ ERROR `Drop` impls cannot be specialized | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<AddsBnd: Bound> Drop for Enum<AddsBnd> { | ||
//~^ ERROR `Drop` impl requires `AddsBnd: Bound` | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<AddsBnd: Bound> Drop for TupleStruct<AddsBnd> { | ||
//~^ ERROR `Drop` impl requires `AddsBnd: Bound` | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<AddsBnd: Copy + Bound> Drop for Union<AddsBnd> { | ||
//~^ ERROR `Drop` impl requires `AddsBnd: Bound` | ||
fn drop(&mut self) {} | ||
} | ||
|
||
pub fn main() {} |
Oops, something went wrong.