File tree 2 files changed +88
-0
lines changed
2 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ // run-pass
2
+ //! Regression test for #58311, regarding the usage of Fn types in drop impls
3
+
4
+ // All of this Drop impls should compile.
5
+
6
+ #[ allow( dead_code) ]
7
+ struct S < F : Fn ( ) -> [ u8 ; 1 ] > ( F ) ;
8
+
9
+ impl < F : Fn ( ) -> [ u8 ; 1 ] > Drop for S < F > {
10
+ fn drop ( & mut self ) { }
11
+ }
12
+
13
+ #[ allow( dead_code) ]
14
+ struct P < A , F : FnOnce ( ) -> [ A ; 10 ] > ( F ) ;
15
+
16
+ impl < A , F : FnOnce ( ) -> [ A ; 10 ] > Drop for P < A , F > {
17
+ fn drop ( & mut self ) { }
18
+ }
19
+
20
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // run-pass
2
+ //! Regression test for #34426, regarding HRTB in drop impls
3
+
4
+ // All of this Drop impls should compile.
5
+
6
+ pub trait Lifetime < ' a > { }
7
+ impl < ' a > Lifetime < ' a > for i32 { }
8
+
9
+ #[ allow( dead_code) ]
10
+ struct Foo < L >
11
+ where
12
+ for < ' a > L : Lifetime < ' a > ,
13
+ {
14
+ l : L ,
15
+ }
16
+
17
+ impl < L > Drop for Foo < L >
18
+ where
19
+ for < ' a > L : Lifetime < ' a > ,
20
+ {
21
+ fn drop ( & mut self ) { }
22
+ }
23
+
24
+ #[ allow( dead_code) ]
25
+ struct Foo2 < L >
26
+ where
27
+ for < ' a > L : Lifetime < ' a > ,
28
+ {
29
+ l : L ,
30
+ }
31
+
32
+ impl < T : for < ' a > Lifetime < ' a > > Drop for Foo2 < T >
33
+ where
34
+ for < ' x > T : Lifetime < ' x > ,
35
+ {
36
+ fn drop ( & mut self ) { }
37
+ }
38
+
39
+ pub trait Lifetime2 < ' a , ' b > { }
40
+ impl < ' a , ' b > Lifetime2 < ' a , ' b > for i32 { }
41
+
42
+ #[ allow( dead_code) ]
43
+ struct Bar < L >
44
+ where
45
+ for < ' a , ' b > L : Lifetime2 < ' a , ' b > ,
46
+ {
47
+ l : L ,
48
+ }
49
+
50
+ impl < L > Drop for Bar < L >
51
+ where
52
+ for < ' a , ' b > L : Lifetime2 < ' a , ' b > ,
53
+ {
54
+ fn drop ( & mut self ) { }
55
+ }
56
+
57
+ #[ allow( dead_code) ]
58
+ struct FnHolder < T : for < ' a > Fn ( & ' a T , dyn for < ' b > Lifetime2 < ' a , ' b > ) -> u8 > ( T ) ;
59
+
60
+ impl < T : for < ' a > Fn ( & ' a T , dyn for < ' b > Lifetime2 < ' a , ' b > ) -> u8 > Drop for FnHolder < T > {
61
+ fn drop ( & mut self ) { }
62
+ }
63
+
64
+ fn main ( ) {
65
+ let _foo = Foo { l : 0 } ;
66
+
67
+ let _bar = Bar { l : 0 } ;
68
+ }
You can’t perform that action at this time.
0 commit comments