]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/clashing-extern-fn-recursion.rs
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / clashing-extern-fn-recursion.rs
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 Reffy2<'a>,
93         }
94
95         struct Reffy2<'a> {
96             reffy: &'a Reffy1<'a>,
97         }
98
99         extern "C" {
100             #[allow(improper_ctypes)]
101             fn reffy_once_removed(reffy: Reffy1);
102         }
103     }
104     mod b {
105         #[repr(C)]
106         struct Reffy1<'a> {
107             reffy: &'a Reffy2<'a>,
108         }
109
110         struct Reffy2<'a> {
111             reffy: &'a Reffy1<'a>,
112         }
113
114         extern "C" {
115             #[allow(improper_ctypes)]
116             fn reffy_once_removed(reffy: Reffy1);
117         }
118     }
119 }