Skip to content

Commit 4b48996

Browse files
bors[bot]taiki-e
andauthored
Merge #211
211: Hide generated items from --document-private-items r=taiki-e a=taiki-e All of the generated items are private items, but it can be displayed in the document by using the `--document-private-items` flag. Naming will be allowed by #202, so it would probably be preferable to only display it in the document if the user did a naming. cc #124 #202 Related: #192 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2 parents dec0b16 + 56430f1 commit 4b48996

11 files changed

+34
-4
lines changed

examples/enum-default-expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ where
4141
Unpinned(&'pin (U)),
4242
}
4343

44+
#[doc(hidden)]
4445
#[allow(non_upper_case_globals)]
4546
const __SCOPE_Enum: () = {
4647
impl<T, U> Enum<T, U> {

examples/pinned_drop-expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ where
5050
field: ::pin_project::__reexport::pin::Pin<&'pin (T)>,
5151
}
5252

53+
#[doc(hidden)]
5354
#[allow(non_upper_case_globals)]
5455
const __SCOPE_Struct: () = {
5556
impl<'a, T> Struct<'a, T> {

examples/struct-default-expanded.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ where
4343
unpinned: &'pin (U),
4444
}
4545

46+
#[doc(hidden)]
4647
#[allow(non_upper_case_globals)]
4748
const __SCOPE_Struct: () = {
4849
impl<T, U> Struct<T, U> {

examples/unsafe_unpin-expanded.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ where
4545
unpinned: &'pin (U),
4646
}
4747

48+
#[doc(hidden)]
4849
#[allow(non_upper_case_globals)]
4950
const __SCOPE_Struct: () = {
5051
impl<T, U> Struct<T, U> {
@@ -72,8 +73,6 @@ const __SCOPE_Struct: () = {
7273
}
7374
}
7475

75-
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
76-
7776
#[allow(single_use_lifetimes)]
7877
impl<'pin, T, U> ::pin_project::__reexport::marker::Unpin for Struct<T, U> where
7978
::pin_project::__private::Wrapper<'pin, Self>: ::pin_project::UnsafeUnpin
@@ -105,4 +104,6 @@ const __SCOPE_Struct: () = {
105104
}
106105
};
107106

107+
unsafe impl<T: Unpin, U> UnsafeUnpin for Struct<T, U> {}
108+
108109
fn main() {}

pin-project-internal/src/pin_project/derive.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub(super) fn parse_derive(input: TokenStream) -> Result<TokenStream> {
4242
// * https://github.com/rust-lang/rust/issues/63281
4343
// * https://github.com/taiki-e/pin-project/pull/53#issuecomment-525906867
4444
// * https://github.com/taiki-e/pin-project/pull/70
45+
#[doc(hidden)]
4546
#[allow(non_upper_case_globals)]
4647
const #dummy_const: () = {
4748
#proj_impl
@@ -66,6 +67,7 @@ pub(super) fn parse_derive(input: TokenStream) -> Result<TokenStream> {
6667

6768
let dummy_const = format_ident!("__SCOPE_{}", ident);
6869
proj_items.extend(quote! {
70+
#[doc(hidden)]
6971
#[allow(non_upper_case_globals)]
7072
const #dummy_const: () = {
7173
#proj_impl
@@ -379,16 +381,18 @@ impl<'a> Context<'a> {
379381
};
380382

381383
let mut proj_items = quote! {
384+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
382385
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`.
383386
#[allow(dead_code)] // This lint warns unused fields/variants.
384387
#vis struct #proj_ident #proj_generics #where_clause_fields
388+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
385389
#[allow(dead_code)] // This lint warns unused fields/variants.
386390
#vis struct #proj_ref_ident #proj_generics #where_clause_ref_fields
387391
};
388-
389392
if self.replace.is_some() {
390393
// Currently, using quote_spanned here does not seem to have any effect on the diagnostics.
391394
proj_items.extend(quote! {
395+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
392396
#[allow(dead_code)] // This lint warns unused fields/variants.
393397
#vis struct #proj_own_ident #orig_generics #where_clause_own_fields
394398
});
@@ -451,20 +455,22 @@ impl<'a> Context<'a> {
451455
let where_clause = &self.proj.where_clause;
452456

453457
let mut proj_items = quote! {
458+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
454459
#[allow(clippy::mut_mut)] // This lint warns `&mut &mut <ty>`.
455460
#[allow(dead_code)] // This lint warns unused fields/variants.
456461
#vis enum #proj_ident #proj_generics #where_clause {
457462
#proj_variants
458463
}
464+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
459465
#[allow(dead_code)] // This lint warns unused fields/variants.
460466
#vis enum #proj_ref_ident #proj_generics #where_clause {
461467
#proj_ref_variants
462468
}
463469
};
464-
465470
if self.replace.is_some() {
466471
// Currently, using quote_spanned here does not seem to have any effect on the diagnostics.
467472
proj_items.extend(quote! {
473+
#[doc(hidden)] // TODO: If the user gave it a name, it should appear in the document.
468474
#[allow(dead_code)] // This lint warns unused fields/variants.
469475
#vis enum #proj_own_ident #orig_generics #orig_where_clause {
470476
#proj_own_variants

tests/expand/tests/enum/default.expanded.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ enum Enum<T, U> {
44
Pinned(#[pin] T),
55
Unpinned(U),
66
}
7+
#[doc(hidden)]
78
#[allow(clippy::mut_mut)]
89
#[allow(dead_code)]
910
enum __EnumProjection<'pin, T, U>
@@ -13,6 +14,7 @@ where
1314
Pinned(::pin_project::__reexport::pin::Pin<&'pin mut (T)>),
1415
Unpinned(&'pin mut (U)),
1516
}
17+
#[doc(hidden)]
1618
#[allow(dead_code)]
1719
enum __EnumProjectionRef<'pin, T, U>
1820
where
@@ -21,6 +23,7 @@ where
2123
Pinned(::pin_project::__reexport::pin::Pin<&'pin (T)>),
2224
Unpinned(&'pin (U)),
2325
}
26+
#[doc(hidden)]
2427
#[allow(non_upper_case_globals)]
2528
const __SCOPE_Enum: () = {
2629
impl<T, U> Enum<T, U> {

tests/expand/tests/enum/project_replace.expanded.rs

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum Enum<T, U> {
88
},
99
None,
1010
}
11+
#[doc(hidden)]
1112
#[allow(clippy::mut_mut)]
1213
#[allow(dead_code)]
1314
enum __EnumProjection<'pin, T, U>
@@ -20,6 +21,7 @@ where
2021
},
2122
None,
2223
}
24+
#[doc(hidden)]
2325
#[allow(dead_code)]
2426
enum __EnumProjectionRef<'pin, T, U>
2527
where
@@ -31,6 +33,7 @@ where
3133
},
3234
None,
3335
}
36+
#[doc(hidden)]
3437
#[allow(dead_code)]
3538
enum __EnumProjectionOwned<T, U> {
3639
V {
@@ -39,6 +42,7 @@ enum __EnumProjectionOwned<T, U> {
3942
},
4043
None,
4144
}
45+
#[doc(hidden)]
4246
#[allow(non_upper_case_globals)]
4347
const __SCOPE_Enum: () = {
4448
impl<T, U> Enum<T, U> {

tests/expand/tests/struct/default.expanded.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct Struct<T, U> {
55
pinned: T,
66
unpinned: U,
77
}
8+
#[doc(hidden)]
89
#[allow(clippy::mut_mut)]
910
#[allow(dead_code)]
1011
struct __StructProjection<'pin, T, U>
@@ -14,6 +15,7 @@ where
1415
pinned: ::pin_project::__reexport::pin::Pin<&'pin mut (T)>,
1516
unpinned: &'pin mut (U),
1617
}
18+
#[doc(hidden)]
1719
#[allow(dead_code)]
1820
struct __StructProjectionRef<'pin, T, U>
1921
where
@@ -22,6 +24,7 @@ where
2224
pinned: ::pin_project::__reexport::pin::Pin<&'pin (T)>,
2325
unpinned: &'pin (U),
2426
}
27+
#[doc(hidden)]
2528
#[allow(non_upper_case_globals)]
2629
const __SCOPE_Struct: () = {
2730
impl<T, U> Struct<T, U> {

tests/expand/tests/struct/pinned_drop.expanded.rs

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub struct Struct<'a, T> {
66
#[pin]
77
field: T,
88
}
9+
#[doc(hidden)]
910
#[allow(clippy::mut_mut)]
1011
#[allow(dead_code)]
1112
pub(crate) struct __StructProjection<'pin, 'a, T>
@@ -15,6 +16,7 @@ where
1516
was_dropped: &'pin mut (&'a mut bool),
1617
field: ::pin_project::__reexport::pin::Pin<&'pin mut (T)>,
1718
}
19+
#[doc(hidden)]
1820
#[allow(dead_code)]
1921
pub(crate) struct __StructProjectionRef<'pin, 'a, T>
2022
where
@@ -23,6 +25,7 @@ where
2325
was_dropped: &'pin (&'a mut bool),
2426
field: ::pin_project::__reexport::pin::Pin<&'pin (T)>,
2527
}
28+
#[doc(hidden)]
2629
#[allow(non_upper_case_globals)]
2730
const __SCOPE_Struct: () = {
2831
impl<'a, T> Struct<'a, T> {

tests/expand/tests/struct/project_replace.expanded.rs

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct Struct<T, U> {
55
pinned: T,
66
unpinned: U,
77
}
8+
#[doc(hidden)]
89
#[allow(clippy::mut_mut)]
910
#[allow(dead_code)]
1011
struct __StructProjection<'pin, T, U>
@@ -14,6 +15,7 @@ where
1415
pinned: ::pin_project::__reexport::pin::Pin<&'pin mut (T)>,
1516
unpinned: &'pin mut (U),
1617
}
18+
#[doc(hidden)]
1719
#[allow(dead_code)]
1820
struct __StructProjectionRef<'pin, T, U>
1921
where
@@ -22,11 +24,13 @@ where
2224
pinned: ::pin_project::__reexport::pin::Pin<&'pin (T)>,
2325
unpinned: &'pin (U),
2426
}
27+
#[doc(hidden)]
2528
#[allow(dead_code)]
2629
struct __StructProjectionOwned<T, U> {
2730
pinned: ::pin_project::__reexport::marker::PhantomData<T>,
2831
unpinned: U,
2932
}
33+
#[doc(hidden)]
3034
#[allow(non_upper_case_globals)]
3135
const __SCOPE_Struct: () = {
3236
impl<T, U> Struct<T, U> {

tests/expand/tests/struct/unsafe_unpin.expanded.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub struct Struct<T, U> {
55
pinned: T,
66
unpinned: U,
77
}
8+
#[doc(hidden)]
89
#[allow(clippy::mut_mut)]
910
#[allow(dead_code)]
1011
pub(crate) struct __StructProjection<'pin, T, U>
@@ -14,6 +15,7 @@ where
1415
pinned: ::pin_project::__reexport::pin::Pin<&'pin mut (T)>,
1516
unpinned: &'pin mut (U),
1617
}
18+
#[doc(hidden)]
1719
#[allow(dead_code)]
1820
pub(crate) struct __StructProjectionRef<'pin, T, U>
1921
where
@@ -22,6 +24,7 @@ where
2224
pinned: ::pin_project::__reexport::pin::Pin<&'pin (T)>,
2325
unpinned: &'pin (U),
2426
}
27+
#[doc(hidden)]
2528
#[allow(non_upper_case_globals)]
2629
const __SCOPE_Struct: () = {
2730
impl<T, U> Struct<T, U> {

0 commit comments

Comments
 (0)