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