Skip to content

Commit

Permalink
Suppress various lints in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 6, 2025
1 parent a3f1fb0 commit 2c26534
Show file tree
Hide file tree
Showing 23 changed files with 684 additions and 348 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Suppress `clippy::absolute_paths`, `clippy::min_ident_chars`, and `clippy::single_char_lifetime_names` lints in generated code.

## [0.2.15] - 2024-10-24

- Work around an issue on negative_impls that allows unsound overlapping `Unpin` implementations. ([#84](https://github.com/taiki-e/pin-project-lite/pull/84))
Expand Down
75 changes: 49 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,18 @@ macro_rules! __pin_project_constant {
}
$($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
#[allow(clippy::used_underscore_binding)]
#[allow(
explicit_outlives_requirements, // https://github.com/rust-lang/rust/issues/60993
single_use_lifetimes, // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::redundant_pub_crate, // This lint warns `pub(crate)` field in private struct.
clippy::single_char_lifetime_names,
clippy::used_underscore_binding
)]
const _: () = {
$crate::__pin_project_make_proj_ty! {
[$($proj_mut_ident)? Projection]
Expand Down Expand Up @@ -627,11 +632,16 @@ macro_rules! __pin_project_constant {
}
$($(#[$drop_impl_attrs:meta])* impl $($pinned_drop:tt)*)?
) => {
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::used_underscore_binding)]
#[allow(
single_use_lifetimes, // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::single_char_lifetime_names,
clippy::used_underscore_binding
)]
const _: () = {
impl<$($impl_generics)*> $ident <$($ty_generics)*>
$(where
Expand Down Expand Up @@ -850,15 +860,20 @@ macro_rules! __pin_project_make_proj_ty_body {
[$($body_data:tt)+]
) => {
#[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
#[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`. (only needed for project_ref)
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
#[allow(
dead_code, // This lint warns unused fields/variants.
single_use_lifetimes, // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut, // This lint warns `&mut &mut <ty>`. (only needed for project)
clippy::redundant_pub_crate, // This lint warns `pub(crate)` field in private struct.
clippy::ref_option_ref, // This lint warns `&Option<&<ty>>`. (only needed for project_ref)
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds // https://github.com/rust-lang/rust-clippy/issues/4326
)]
$proj_vis $struct_ty_ident $proj_ty_ident <'__pin, $($impl_generics)*>
where
$ident <$($ty_generics)*>: '__pin
Expand Down Expand Up @@ -944,11 +959,19 @@ macro_rules! __pin_project_make_proj_replace_ty_body {
[$($body_data:tt)+]
) => {
#[doc(hidden)] // Workaround for rustc bug: see https://github.com/taiki-e/pin-project-lite/issues/77#issuecomment-1671540180 for more.
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`. (only needed for project)
#[allow(clippy::redundant_pub_crate)] // This lint warns `pub(crate)` field in private struct.
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
#[allow(
dead_code, // This lint warns unused fields/variants.
single_use_lifetimes, // https://github.com/rust-lang/rust/issues/55058
// This lint warns of `clippy::*` generated by external macros.
// We allow this lint for compatibility with older compilers.
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut, // This lint warns `&mut &mut <ty>`. (only needed for project)
clippy::redundant_pub_crate, // This lint warns `pub(crate)` field in private struct.
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds // https://github.com/rust-lang/rust-clippy/issues/4326
)]
$proj_vis $struct_ty_ident $proj_ty_ident <$($impl_generics)*>
where
$($($where_clause)*)?
Expand Down
65 changes: 43 additions & 22 deletions tests/expand/default/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ enum Enum<T, U> {
Unit,
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::ref_option_ref,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
enum EnumProj<'__pin, T, U>
where
Enum<T, U>: '__pin,
Expand All @@ -22,13 +27,18 @@ where
Unit,
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::ref_option_ref,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
enum EnumProjRef<'__pin, T, U>
where
Enum<T, U>: '__pin,
Expand All @@ -40,18 +50,29 @@ where
Unit,
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
enum EnumProjReplace<T, U> {
Struct { pinned: ::pin_project_lite::__private::PhantomData<T>, unpinned: U },
Unit,
}
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::used_underscore_binding)]
#[allow(
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::single_char_lifetime_names,
clippy::used_underscore_binding
)]
const _: () = {
impl<T, U> Enum<T, U> {
#[doc(hidden)]
Expand Down
53 changes: 34 additions & 19 deletions tests/expand/default/struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@ struct Struct<T, U> {
pinned: T,
unpinned: U,
}
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::used_underscore_binding)]
#[allow(
explicit_outlives_requirements,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::redundant_pub_crate,
clippy::single_char_lifetime_names,
clippy::used_underscore_binding
)]
const _: () = {
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::ref_option_ref,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
struct Projection<'__pin, T, U>
where
Struct<T, U>: '__pin,
Expand All @@ -25,13 +35,18 @@ const _: () = {
unpinned: &'__pin mut (U),
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::ref_option_ref,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
struct ProjectionRef<'__pin, T, U>
where
Struct<T, U>: '__pin,
Expand Down
27 changes: 19 additions & 8 deletions tests/expand/multifields/enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ enum Enum<T, U> {
Unit,
}
#[doc(hidden)]
#[allow(dead_code)]
#[allow(single_use_lifetimes)]
#[allow(clippy::mut_mut)]
#[allow(clippy::redundant_pub_crate)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(
dead_code,
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::mut_mut,
clippy::redundant_pub_crate,
clippy::single_char_lifetime_names,
clippy::type_repetition_in_bounds
)]
enum EnumProjReplace<T, U> {
Struct {
pinned1: ::pin_project_lite::__private::PhantomData<T>,
Expand All @@ -18,9 +24,14 @@ enum EnumProjReplace<T, U> {
},
Unit,
}
#[allow(single_use_lifetimes)]
#[allow(clippy::unknown_clippy_lints)]
#[allow(clippy::used_underscore_binding)]
#[allow(
single_use_lifetimes,
clippy::unknown_clippy_lints,
clippy::absolute_paths,
clippy::min_ident_chars,
clippy::single_char_lifetime_names,
clippy::used_underscore_binding
)]
const _: () = {
impl<T, U> Enum<T, U> {
#[doc(hidden)]
Expand Down
Loading

0 comments on commit 2c26534

Please sign in to comment.