Skip to content

Commit

Permalink
Suppress clippy::ref_option_ref lint in generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 9, 2021
1 parent 5ebc0e7 commit b7f6562
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- Suppress `clippy::ref_option_ref` lint in generated code.

## [1.0.3] - 2021-01-05

- Exclude unneeded files from crates.io.
Expand Down
1 change: 1 addition & 0 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn proj_allowed_lints(kind: TypeKind) -> (TokenStream, TokenStream, TokenStream)
let proj_ref = quote! {
#global_allowed_lints
#[allow(dead_code)] // This lint warns unused fields/variants.
#[allow(clippy::ref_option_ref)] // This lint warns `&Option<&<ty>>`.
#[allow(clippy::type_repetition_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/4326
};
let proj_own = quote! {
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/default-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/default-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/default-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/multifields-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/multifields-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-enum-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum ProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-enum-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum Enum<T, U> {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum ProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct ProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct-none.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct-own.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-struct-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct Struct<T, U> {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct ProjRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct ProjRef<'pin, T, U>(::pin_project::__private::Pin<&'pin (T)>, &'pin (U))
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct TupleStruct<T, U>(#[pin] T, U);
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct ProjRef<'pin, T, U>(::pin_project::__private::Pin<&'pin (T)>, &'pin (U))
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/not_unpin-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/not_unpin-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/pinned_drop-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/pinned_drop-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/pub-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
pub(crate) enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/pub-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
pub(crate) struct __StructProjectionRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/pub-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
pub(crate) struct __TupleStructProjectionRef<'pin, T, U>(
pub ::pin_project::__private::Pin<&'pin (T)>,
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/unsafe_unpin-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
enum EnumProjRef<'pin, T, U>
where
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/unsafe_unpin-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __StructProjectionRef<'pin, T, U>
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const _: () = {
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
#[allow(dead_code)]
#[allow(clippy::ref_option_ref)]
#[allow(clippy::type_repetition_in_bounds)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
Expand Down
22 changes: 22 additions & 0 deletions tests/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,28 @@ pub mod clippy_used_underscore_binding {
}
}

pub mod clippy_ref_option_ref {
use pin_project::pin_project;

#[pin_project]
#[derive(Debug)]
pub struct Struct<'a> {
#[pin]
pub _pinned: Option<&'a ()>,
pub _unpinned: Option<&'a ()>,
}

#[pin_project(project = EnumProj, project_ref = EnumProjRef)]
#[derive(Debug)]
pub enum Enum<'a> {
Struct {
#[pin]
_pinned: Option<&'a ()>,
_unpinned: Option<&'a ()>,
},
}
}

// Run `./dev.sh +$toolchain test --test lint` to update this.
#[cfg(not(miri))]
#[allow(clippy::restriction)]
Expand Down

0 comments on commit b7f6562

Please sign in to comment.