1
1
// Issue 8142: Test that Drop impls cannot be specialized beyond the
2
- // predicates attached to the struct/enum definition itself.
2
+ // predicates attached to the type definition itself.
3
3
4
4
trait Bound { fn foo ( & self ) { } }
5
5
struct K < ' l1 , ' l2 > { x : & ' l1 i8 , y : & ' l2 u8 }
@@ -16,12 +16,16 @@ struct U;
16
16
struct V < Tva , Tvb > { x : * const Tva , y : * const Tvb }
17
17
struct W < ' l1 , ' l2 > { x : & ' l1 i8 , y : & ' l2 u8 }
18
18
19
+ enum Enum < T > { Variant ( T ) }
20
+ struct TupleStruct < T > ( T ) ;
21
+ union Union < T : Copy > { f : T }
22
+
19
23
impl < ' 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.
24
+ //~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
21
25
fn drop ( & mut self ) { } }
22
26
23
27
impl < ' 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.
28
+ //~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
25
29
fn drop ( & mut self ) { } }
26
30
27
31
impl < ' ml > Drop for M < ' ml > { fn drop ( & mut self ) { } } // ACCEPT
@@ -34,13 +38,13 @@ impl Drop for N<'static> { fn drop(&mut self) { } } // RE
34
38
impl < COkNoBound > Drop for O < COkNoBound > { fn drop ( & mut self ) { } } // ACCEPT
35
39
36
40
impl Drop for P < i8 > { fn drop ( & mut self ) { } } // REJECT
37
- //~^ ERROR Implementations of Drop cannot be specialized
41
+ //~^ ERROR ` Drop` impls cannot be specialized
38
42
39
43
impl < AddsBnd : Bound > Drop for Q < AddsBnd > { fn drop ( & mut self ) { } } // REJECT
40
- //~^ ERROR The requirement `AddsBnd: Bound` is added only by the Drop impl.
44
+ //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
41
45
42
46
impl < ' 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.
47
+ //~^ ERROR `Drop` impl requires `AddsRBnd : 'rbnd`
44
48
45
49
impl < Bs : Bound > Drop for S < Bs > { fn drop ( & mut self ) { } } // ACCEPT
46
50
@@ -49,9 +53,18 @@ impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
49
53
impl Drop for U { fn drop ( & mut self ) { } } // ACCEPT
50
54
51
55
impl < One > Drop for V < One , One > { fn drop ( & mut self ) { } } // REJECT
52
- //~^ ERROR Implementations of Drop cannot be specialized
56
+ //~^ ERROR ` Drop` impls cannot be specialized
53
57
54
58
impl < ' lw > Drop for W < ' lw , ' lw > { fn drop ( & mut self ) { } } // REJECT
55
59
//~^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'lw`
56
60
61
+ impl < AddsBnd : Bound > Drop for Enum < AddsBnd > { fn drop ( & mut self ) { } } // REJECT
62
+ //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
63
+
64
+ impl < AddsBnd : Bound > Drop for TupleStruct < AddsBnd > { fn drop ( & mut self ) { } } // REJECT
65
+ //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
66
+
67
+ impl < AddsBnd : Copy + Bound > Drop for Union < AddsBnd > { fn drop ( & mut self ) { } } // REJECT
68
+ //~^ ERROR `Drop` impl requires `AddsBnd: Bound`
69
+
57
70
pub fn main ( ) { }
0 commit comments