File tree Expand file tree Collapse file tree 1 file changed +117
-0
lines changed Expand file tree Collapse file tree 1 file changed +117
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+ //
3
+ // This tests checks that clashing_extern_declarations handles types that are recursive through a
4
+ // pointer or ref argument. See #75512.
5
+
6
+ #![ crate_type = "lib" ]
7
+
8
+ mod raw_ptr_recursion {
9
+ mod a {
10
+ #[ repr( C ) ]
11
+ struct Pointy {
12
+ pointy : * const Pointy ,
13
+ }
14
+
15
+ extern "C" {
16
+ fn run_pointy ( pointy : Pointy ) ;
17
+ }
18
+ }
19
+ mod b {
20
+ #[ repr( C ) ]
21
+ struct Pointy {
22
+ pointy : * const Pointy ,
23
+ }
24
+
25
+ extern "C" {
26
+ fn run_pointy ( pointy : Pointy ) ;
27
+ }
28
+ }
29
+ }
30
+
31
+ mod raw_ptr_recursion_once_removed {
32
+ mod a {
33
+ #[ repr( C ) ]
34
+ struct Pointy1 {
35
+ pointy_two : * const Pointy2 ,
36
+ }
37
+
38
+ #[ repr( C ) ]
39
+ struct Pointy2 {
40
+ pointy_one : * const Pointy1 ,
41
+ }
42
+
43
+ extern "C" {
44
+ fn run_pointy2 ( pointy : Pointy2 ) ;
45
+ }
46
+ }
47
+
48
+ mod b {
49
+ #[ repr( C ) ]
50
+ struct Pointy1 {
51
+ pointy_two : * const Pointy2 ,
52
+ }
53
+
54
+ #[ repr( C ) ]
55
+ struct Pointy2 {
56
+ pointy_one : * const Pointy1 ,
57
+ }
58
+
59
+ extern "C" {
60
+ fn run_pointy2 ( pointy : Pointy2 ) ;
61
+ }
62
+ }
63
+ }
64
+
65
+ mod ref_recursion {
66
+ mod a {
67
+ #[ repr( C ) ]
68
+ struct Reffy < ' a > {
69
+ reffy : & ' a Reffy < ' a > ,
70
+ }
71
+
72
+ extern "C" {
73
+ fn reffy_recursion ( reffy : Reffy ) ;
74
+ }
75
+ }
76
+ mod b {
77
+ #[ repr( C ) ]
78
+ struct Reffy < ' a > {
79
+ reffy : & ' a Reffy < ' a > ,
80
+ }
81
+
82
+ extern "C" {
83
+ fn reffy_recursion ( reffy : Reffy ) ;
84
+ }
85
+ }
86
+ }
87
+
88
+ mod ref_recursion_once_removed {
89
+ mod a {
90
+ #[ repr( C ) ]
91
+ struct Reffy1 < ' a > {
92
+ reffy : & ' a Reffy1 < ' a > ,
93
+ }
94
+
95
+ struct Reffy2 < ' a > {
96
+ reffy : & ' a Reffy2 < ' a > ,
97
+ }
98
+
99
+ extern "C" {
100
+ fn reffy_once_removed ( reffy : Reffy1 ) ;
101
+ }
102
+ }
103
+ mod b {
104
+ #[ repr( C ) ]
105
+ struct Reffy1 < ' a > {
106
+ reffy : & ' a Reffy1 < ' a > ,
107
+ }
108
+
109
+ struct Reffy2 < ' a > {
110
+ reffy : & ' a Reffy2 < ' a > ,
111
+ }
112
+
113
+ extern "C" {
114
+ fn reffy_once_removed ( reffy : Reffy1 ) ;
115
+ }
116
+ }
117
+ }
You can’t perform that action at this time.
0 commit comments