Skip to content

Commit

Permalink
Merge #284
Browse files Browse the repository at this point in the history
284: Allow clippy::redundant_pub_crate r=taiki-e a=dnaka91

This is my first PR to this project so please bear with me. 

While using this crate in my project I noticed that the clippy::redundant_pub_crate (part of clippy::nursery) came up when I was using the derive macro in a module within a binary crate.

For example my trimmed down project layout is like this:
```
src/main.rs
src/services/log.rs <-- using the pin_project derive macro here creates a clippy warning
```

This change allows the clippy::redundant_pub_crate lint on all generated code to silence the lint messages. I hope this is the right spot to add the `#[allow(...)]` attribute.

Co-authored-by: Dominik Nakamura <dnaka91@gmail.com>
  • Loading branch information
bors[bot] and dnaka91 authored Oct 2, 2020
2 parents 334de32 + 4859555 commit 2f535d0
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 0 deletions.
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 @@ -150,6 +150,7 @@ fn global_allowed_lints() -> TokenStream {
#[allow(explicit_outlives_requirements)] // https://github.com/rust-lang/rust/issues/60993
#[allow(single_use_lifetimes)] // https://github.com/rust-lang/rust/issues/55058
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
}
}

Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/default-enum.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum EnumProj<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -33,6 +34,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum EnumProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -51,6 +53,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {
fn project<'pin>(
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/default-struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -20,6 +21,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -33,6 +35,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/default-tuple_struct.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct TupleStruct<T, U>(#[pin] T, U);
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -16,6 +17,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
Expand All @@ -28,6 +30,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
Expand Down
4 changes: 4 additions & 0 deletions tests/expand/tests/expand/naming-enum-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -33,6 +34,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -51,6 +53,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum ProjOwn<T, U> {
Struct {
pinned: ::pin_project::__private::PhantomData<T>,
Expand All @@ -66,6 +69,7 @@ enum ProjOwn<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {
fn project<'pin>(self: ::pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/tests/expand/naming-enum-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum Proj<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -34,6 +35,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {
fn project<'pin>(self: ::pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, T, U> {
Expand Down
1 change: 1 addition & 0 deletions tests/expand/tests/expand/naming-enum-none.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {}
struct __Enum<'pin, T, U> {
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/tests/expand/naming-enum-own.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum ProjOwn<T, U> {
Struct {
pinned: ::pin_project::__private::PhantomData<T>,
Expand All @@ -31,6 +32,7 @@ enum ProjOwn<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {
fn project_replace(
Expand Down
2 changes: 2 additions & 0 deletions tests/expand/tests/expand/naming-enum-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum Enum<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
enum ProjRef<'pin, T, U>
where
Enum<T, U>: 'pin,
Expand All @@ -33,6 +34,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Enum<T, U> {
fn project_ref<'pin>(
Expand Down
4 changes: 4 additions & 0 deletions tests/expand/tests/expand/naming-struct-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -25,6 +26,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -38,6 +40,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
Expand All @@ -49,6 +52,7 @@ struct ProjOwn<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> Struct<T, U> {
fn project<'pin>(self: ::pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, T, U> {
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/naming-struct-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct Proj<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -26,13 +27,15 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(box_pointers)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/naming-struct-none.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -20,6 +21,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -33,6 +35,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand Down
4 changes: 4 additions & 0 deletions tests/expand/tests/expand/naming-struct-own.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjOwn<T, U> {
pinned: ::pin_project::__private::PhantomData<T>,
unpinned: U,
Expand All @@ -22,6 +23,7 @@ struct ProjOwn<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -30,6 +32,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -43,6 +46,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjectionRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/naming-struct-ref.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct Struct<T, U> {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjRef<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand All @@ -25,6 +26,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -33,6 +35,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __StructProjection<'pin, T, U>
where
Struct<T, U>: 'pin,
Expand Down
4 changes: 4 additions & 0 deletions tests/expand/tests/expand/naming-tuple_struct-all.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct TupleStruct<T, U>(#[pin] T, U);
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct Proj<'pin, T, U>(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U))
where
TupleStruct<T, U>: 'pin;
Expand All @@ -17,6 +18,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjRef<'pin, T, U>(::pin_project::__private::Pin<&'pin (T)>, &'pin (U))
where
TupleStruct<T, U>: 'pin;
Expand All @@ -26,6 +28,7 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[doc(hidden)]
#[allow(non_upper_case_globals)]
Expand All @@ -34,6 +37,7 @@ struct ProjOwn<T, U>(::pin_project::__private::PhantomData<T>, U);
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
impl<T, U> TupleStruct<T, U> {
fn project<'pin>(self: ::pin_project::__private::Pin<&'pin mut Self>) -> Proj<'pin, T, U> {
Expand Down
3 changes: 3 additions & 0 deletions tests/expand/tests/expand/naming-tuple_struct-mut.expanded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct TupleStruct<T, U>(#[pin] T, U);
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct Proj<'pin, T, U>(::pin_project::__private::Pin<&'pin mut (T)>, &'pin mut (U))
where
TupleStruct<T, U>: 'pin;
Expand All @@ -18,13 +19,15 @@ where
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::type_repetition_in_bounds)]
#[allow(box_pointers)]
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct TupleStruct<T, U>(#[pin] T, U);
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
const _: () = {
#[allow(dead_code)]
#[allow(clippy::mut_mut)]
Expand All @@ -16,6 +17,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __TupleStructProjection<'pin, T, U>(
::pin_project::__private::Pin<&'pin mut (T)>,
&'pin mut (U),
Expand All @@ -28,6 +30,7 @@ const _: () = {
#[allow(explicit_outlives_requirements)]
#[allow(single_use_lifetimes)]
#[allow(clippy::pattern_type_mismatch)]
#[allow(clippy::redundant_pub_crate)]
struct __TupleStructProjectionRef<'pin, T, U>(
::pin_project::__private::Pin<&'pin (T)>,
&'pin (U),
Expand Down
Loading

0 comments on commit 2f535d0

Please sign in to comment.