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