]> git.proxmox.com Git - rustc.git/blob - vendor/pin-project-lite/tests/lint.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / vendor / pin-project-lite / tests / lint.rs
1 #![forbid(unsafe_code)]
2 #![warn(nonstandard_style, rust_2018_idioms, rustdoc, unused)]
3 // Note: This does not guarantee compatibility with forbidding these lints in the future.
4 // If rustc adds a new lint, we may not be able to keep this.
5 #![forbid(future_incompatible, rust_2018_compatibility)]
6 #![allow(unknown_lints)] // for old compilers
7 #![warn(
8 box_pointers,
9 deprecated_in_future,
10 disjoint_capture_drop_reorder,
11 elided_lifetimes_in_paths,
12 explicit_outlives_requirements,
13 macro_use_extern_crate,
14 meta_variable_misuse,
15 missing_abi,
16 missing_copy_implementations,
17 missing_crate_level_docs,
18 missing_debug_implementations,
19 missing_docs,
20 non_ascii_idents,
21 single_use_lifetimes,
22 trivial_casts,
23 trivial_numeric_casts,
24 unaligned_references,
25 unreachable_pub,
26 unused_extern_crates,
27 unused_import_braces,
28 unused_lifetimes,
29 unused_qualifications,
30 unused_results,
31 variant_size_differences
32 )]
33 // absolute_paths_not_starting_with_crate, anonymous_parameters, keyword_idents, pointer_structural_match, semicolon_in_expressions_from_macros: forbidden as a part of future_incompatible
34 // missing_doc_code_examples, private_doc_tests, invalid_html_tags: warned as a part of rustdoc
35 // unsafe_block_in_unsafe_fn: unstable
36 // unsafe_code: forbidden
37 // unstable_features: deprecated: https://doc.rust-lang.org/beta/rustc/lints/listing/allowed-by-default.html#unstable-features
38 // unused_crate_dependencies: unrelated
39 #![warn(clippy::all, clippy::pedantic, clippy::nursery)]
40 #![warn(clippy::restriction)]
41 #![allow(clippy::blanket_clippy_restriction_lints)] // this is a test, so enable all restriction lints intentionally.
42 #![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] // TODO
43
44 // Check interoperability with rustc and clippy lints.
45
46 pub mod basic {
47 include!("include/basic.rs");
48 }
49
50 pub mod box_pointers {
51 use pin_project_lite::pin_project;
52
53 pin_project! {
54 #[derive(Debug)]
55 pub struct Struct {
56 #[pin]
57 pub p: Box<isize>,
58 pub u: Box<isize>,
59 }
60 }
61
62 pin_project! {
63 #[project = EnumProj]
64 #[project_ref = EnumProjRef]
65 #[derive(Debug)]
66 pub enum Enum {
67 Struct {
68 #[pin]
69 p: Box<isize>,
70 u: Box<isize>,
71 },
72 Unit,
73 }
74 }
75 }
76
77 pub mod explicit_outlives_requirements {
78 use pin_project_lite::pin_project;
79
80 pin_project! {
81 #[derive(Debug)]
82 pub struct Struct<'a, T, U>
83 where
84 T: ?Sized,
85 U: ?Sized,
86 {
87 #[pin]
88 pub pinned: &'a mut T,
89 pub unpinned: &'a mut U,
90 }
91 }
92
93 pin_project! {
94 #[project = EnumProj]
95 #[project_ref = EnumProjRef]
96 #[derive(Debug)]
97 pub enum Enum<'a, T, U>
98 where
99 T: ?Sized,
100 U: ?Sized,
101 {
102 Struct {
103 #[pin]
104 pinned: &'a mut T,
105 unpinned: &'a mut U,
106 },
107 Unit,
108 }
109 }
110 }
111
112 pub mod variant_size_differences {
113 use pin_project_lite::pin_project;
114
115 pin_project! {
116 #[project = EnumProj]
117 #[project_ref = EnumProjRef]
118 #[allow(missing_debug_implementations, missing_copy_implementations)] // https://github.com/rust-lang/rust/pull/74060
119 #[allow(variant_size_differences)] // for the type itself
120 #[allow(clippy::large_enum_variant)] // for the type itself
121 pub enum Enum {
122 V1 { f: u8 },
123 V2 { f: [u8; 1024] },
124 }
125 }
126 }
127
128 pub mod clippy_mut_mut {
129 use pin_project_lite::pin_project;
130
131 pin_project! {
132 #[derive(Debug)]
133 pub struct Struct<'a, T, U> {
134 #[pin]
135 pub pinned: &'a mut T,
136 pub unpinned: &'a mut U,
137 }
138 }
139
140 pin_project! {
141 #[project = EnumProj]
142 #[project_ref = EnumProjRef]
143 #[derive(Debug)]
144 pub enum Enum<'a, T, U> {
145 Struct {
146 #[pin]
147 pinned: &'a mut T,
148 unpinned: &'a mut U,
149 },
150 Unit,
151 }
152 }
153 }
154
155 #[allow(unreachable_pub)]
156 mod clippy_redundant_pub_crate {
157 use pin_project_lite::pin_project;
158
159 pin_project! {
160 #[derive(Debug)]
161 pub struct Struct<T, U> {
162 #[pin]
163 pub pinned: T,
164 pub unpinned: U,
165 }
166 }
167
168 #[allow(dead_code)]
169 pin_project! {
170 #[project = EnumProj]
171 #[project_ref = EnumProjRef]
172 #[derive(Debug)]
173 pub enum Enum<T, U> {
174 Struct {
175 #[pin]
176 pinned: T,
177 unpinned: U,
178 },
179 Unit,
180 }
181 }
182 }
183
184 pub mod clippy_type_repetition_in_bounds {
185 use pin_project_lite::pin_project;
186
187 pin_project! {
188 #[derive(Debug)]
189 pub struct Struct<T, U>
190 where
191 Struct<T, U>: Sized,
192 {
193 #[pin]
194 pub pinned: T,
195 pub unpinned: U,
196 }
197 }
198
199 pin_project! {
200 #[project = EnumProj]
201 #[project_ref = EnumProjRef]
202 #[derive(Debug)]
203 pub enum Enum<T, U>
204 where
205 Enum<T, U>: Sized,
206 {
207 Struct {
208 #[pin]
209 pinned: T,
210 unpinned: U,
211 },
212 Unit,
213 }
214 }
215 }
216
217 pub mod clippy_used_underscore_binding {
218 use pin_project_lite::pin_project;
219
220 pin_project! {
221 #[derive(Debug)]
222 pub struct Struct<T, U> {
223 #[pin]
224 pub _pinned: T,
225 pub _unpinned: U,
226 }
227 }
228
229 pin_project! {
230 #[project = EnumProj]
231 #[project_ref = EnumProjRef]
232 #[derive(Debug)]
233 pub enum Enum<T, U> {
234 Struct {
235 #[pin]
236 _pinned: T,
237 _unpinned: U,
238 },
239 }
240 }
241 }
242
243 pub mod clippy_ref_option_ref {
244 use pin_project_lite::pin_project;
245
246 pin_project! {
247 pub struct Struct<'a> {
248 #[pin]
249 pub _pinned: Option<&'a ()>,
250 pub _unpinned: Option<&'a ()>,
251 }
252 }
253
254 pin_project! {
255 #[project = EnumProj]
256 #[project_ref = EnumProjRef]
257 pub enum Enum<'a> {
258 Struct {
259 #[pin]
260 _pinned: Option<&'a ()>,
261 _unpinned: Option<&'a ()>,
262 },
263 }
264 }
265 }