diff options
author | David Tolnay <dtolnay@gmail.com> | 2021-03-25 02:05:20 -0400 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2021-03-25 02:05:22 -0400 |
commit | b99359bbf31b083573d25b4762d33a3113455444 (patch) | |
tree | 1d933cdd4d6397c7bc15925113c48dd923ee32ad | |
parent | 9291d52a37bce8c274860457369fa6b31c943f07 (diff) | |
download | cxx-b99359bbf31b083573d25b4762d33a3113455444.tar.gz |
Hide all private trait methods from rustdoc
-rw-r--r-- | macro/src/expand.rs | 27 | ||||
-rw-r--r-- | src/cxx_vector.rs | 16 | ||||
-rw-r--r-- | src/shared_ptr.rs | 6 | ||||
-rw-r--r-- | src/unique_ptr.rs | 12 | ||||
-rw-r--r-- | src/weak_ptr.rs | 6 |
5 files changed, 67 insertions, 0 deletions
diff --git a/macro/src/expand.rs b/macro/src/expand.rs index 49b8927b..042fdcb9 100644 --- a/macro/src/expand.rs +++ b/macro/src/expand.rs @@ -1255,6 +1255,7 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) || types.aliases.contains_key(ident); let new_method = if can_construct_from_value { Some(quote! { + #[doc(hidden)] fn __new(value: Self) -> *mut ::std::ffi::c_void { extern "C" { #[link_name = #link_uninit] @@ -1276,9 +1277,11 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) quote_spanned! {end_span=> #unsafe_token impl #impl_generics ::cxx::private::UniquePtrTarget for #ident #ty_generics { + #[doc(hidden)] fn __typename(f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.write_str(#name) } + #[doc(hidden)] fn __null() -> *mut ::std::ffi::c_void { extern "C" { #[link_name = #link_null] @@ -1289,6 +1292,7 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) repr } #new_method + #[doc(hidden)] unsafe fn __raw(raw: *mut Self) -> *mut ::std::ffi::c_void { extern "C" { #[link_name = #link_raw] @@ -1298,6 +1302,7 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) __raw(&mut repr, raw.cast()); repr } + #[doc(hidden)] unsafe fn __get(repr: *mut ::std::ffi::c_void) -> *const Self { extern "C" { #[link_name = #link_get] @@ -1305,6 +1310,7 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) } __get(&repr).cast() } + #[doc(hidden)] unsafe fn __release(mut repr: *mut ::std::ffi::c_void) -> *mut Self { extern "C" { #[link_name = #link_release] @@ -1312,6 +1318,7 @@ fn expand_unique_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) } __release(&mut repr).cast() } + #[doc(hidden)] unsafe fn __drop(mut repr: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_drop] @@ -1344,6 +1351,7 @@ fn expand_shared_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) || types.aliases.contains_key(ident); let new_method = if can_construct_from_value { Some(quote! { + #[doc(hidden)] unsafe fn __new(value: Self, new: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_uninit] @@ -1363,9 +1371,11 @@ fn expand_shared_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) quote_spanned! {end_span=> #unsafe_token impl #impl_generics ::cxx::private::SharedPtrTarget for #ident #ty_generics { + #[doc(hidden)] fn __typename(f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.write_str(#name) } + #[doc(hidden)] unsafe fn __null(new: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_null] @@ -1374,6 +1384,7 @@ fn expand_shared_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) __null(new); } #new_method + #[doc(hidden)] unsafe fn __clone(this: *const ::std::ffi::c_void, new: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_clone] @@ -1381,6 +1392,7 @@ fn expand_shared_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) } __clone(this, new); } + #[doc(hidden)] unsafe fn __get(this: *const ::std::ffi::c_void) -> *const Self { extern "C" { #[link_name = #link_get] @@ -1388,6 +1400,7 @@ fn expand_shared_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) } __get(this).cast() } + #[doc(hidden)] unsafe fn __drop(this: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_drop] @@ -1422,9 +1435,11 @@ fn expand_weak_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) - quote_spanned! {end_span=> #unsafe_token impl #impl_generics ::cxx::private::WeakPtrTarget for #ident #ty_generics { + #[doc(hidden)] fn __typename(f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.write_str(#name) } + #[doc(hidden)] unsafe fn __null(new: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_null] @@ -1432,6 +1447,7 @@ fn expand_weak_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) - } __null(new); } + #[doc(hidden)] unsafe fn __clone(this: *const ::std::ffi::c_void, new: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_clone] @@ -1439,6 +1455,7 @@ fn expand_weak_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) - } __clone(this, new); } + #[doc(hidden)] unsafe fn __downgrade(shared: *const ::std::ffi::c_void, weak: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_downgrade] @@ -1446,6 +1463,7 @@ fn expand_weak_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) - } __downgrade(shared, weak); } + #[doc(hidden)] unsafe fn __upgrade(weak: *const ::std::ffi::c_void, shared: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_upgrade] @@ -1453,6 +1471,7 @@ fn expand_weak_ptr(ident: &Ident, types: &Types, explicit_impl: Option<&Impl>) - } __upgrade(weak, shared); } + #[doc(hidden)] unsafe fn __drop(this: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_drop] @@ -1493,9 +1512,11 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) quote_spanned! {end_span=> #unsafe_token impl #impl_generics ::cxx::private::VectorElement for #elem #ty_generics { + #[doc(hidden)] fn __typename(f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.write_str(#name) } + #[doc(hidden)] fn __vector_size(v: &::cxx::CxxVector<Self>) -> usize { extern "C" { #[link_name = #link_size] @@ -1503,6 +1524,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) } unsafe { __vector_size(v) } } + #[doc(hidden)] unsafe fn __get_unchecked(v: *mut ::cxx::CxxVector<Self>, pos: usize) -> *mut Self { extern "C" { #[link_name = #link_get_unchecked] @@ -1510,6 +1532,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) } __get_unchecked(v, pos) } + #[doc(hidden)] fn __unique_ptr_null() -> *mut ::std::ffi::c_void { extern "C" { #[link_name = #link_unique_ptr_null] @@ -1519,6 +1542,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) unsafe { __unique_ptr_null(&mut repr) } repr } + #[doc(hidden)] unsafe fn __unique_ptr_raw(raw: *mut ::cxx::CxxVector<Self>) -> *mut ::std::ffi::c_void { extern "C" { #[link_name = #link_unique_ptr_raw] @@ -1528,6 +1552,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) __unique_ptr_raw(&mut repr, raw); repr } + #[doc(hidden)] unsafe fn __unique_ptr_get(repr: *mut ::std::ffi::c_void) -> *const ::cxx::CxxVector<Self> { extern "C" { #[link_name = #link_unique_ptr_get] @@ -1535,6 +1560,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) } __unique_ptr_get(&repr) } + #[doc(hidden)] unsafe fn __unique_ptr_release(mut repr: *mut ::std::ffi::c_void) -> *mut ::cxx::CxxVector<Self> { extern "C" { #[link_name = #link_unique_ptr_release] @@ -1542,6 +1568,7 @@ fn expand_cxx_vector(elem: &Ident, explicit_impl: Option<&Impl>, types: &Types) } __unique_ptr_release(&mut repr) } + #[doc(hidden)] unsafe fn __unique_ptr_drop(mut repr: *mut ::std::ffi::c_void) { extern "C" { #[link_name = #link_unique_ptr_drop] diff --git a/src/cxx_vector.rs b/src/cxx_vector.rs index b7ea110e..16433417 100644 --- a/src/cxx_vector.rs +++ b/src/cxx_vector.rs @@ -289,13 +289,21 @@ where /// Writing the same generic function without a `VectorElement` trait bound /// would not compile. pub unsafe trait VectorElement: Sized { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result; + #[doc(hidden)] fn __vector_size(v: &CxxVector<Self>) -> usize; + #[doc(hidden)] unsafe fn __get_unchecked(v: *mut CxxVector<Self>, pos: usize) -> *mut Self; + #[doc(hidden)] fn __unique_ptr_null() -> *mut c_void; + #[doc(hidden)] unsafe fn __unique_ptr_raw(raw: *mut CxxVector<Self>) -> *mut c_void; + #[doc(hidden)] unsafe fn __unique_ptr_get(repr: *mut c_void) -> *const CxxVector<Self>; + #[doc(hidden)] unsafe fn __unique_ptr_release(repr: *mut c_void) -> *mut CxxVector<Self>; + #[doc(hidden)] unsafe fn __unique_ptr_drop(repr: *mut c_void); } @@ -304,9 +312,11 @@ macro_rules! impl_vector_element { const_assert_eq!(1, mem::align_of::<CxxVector<$ty>>()); unsafe impl VectorElement for $ty { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result { f.write_str($name) } + #[doc(hidden)] fn __vector_size(v: &CxxVector<$ty>) -> usize { extern "C" { attr! { @@ -316,6 +326,7 @@ macro_rules! impl_vector_element { } unsafe { __vector_size(v) } } + #[doc(hidden)] unsafe fn __get_unchecked(v: *mut CxxVector<$ty>, pos: usize) -> *mut $ty { extern "C" { attr! { @@ -325,6 +336,7 @@ macro_rules! impl_vector_element { } __get_unchecked(v, pos) } + #[doc(hidden)] fn __unique_ptr_null() -> *mut c_void { extern "C" { attr! { @@ -336,6 +348,7 @@ macro_rules! impl_vector_element { unsafe { __unique_ptr_null(&mut repr) } repr } + #[doc(hidden)] unsafe fn __unique_ptr_raw(raw: *mut CxxVector<Self>) -> *mut c_void { extern "C" { attr! { @@ -347,6 +360,7 @@ macro_rules! impl_vector_element { __unique_ptr_raw(&mut repr, raw); repr } + #[doc(hidden)] unsafe fn __unique_ptr_get(repr: *mut c_void) -> *const CxxVector<Self> { extern "C" { attr! { @@ -356,6 +370,7 @@ macro_rules! impl_vector_element { } __unique_ptr_get(&repr) } + #[doc(hidden)] unsafe fn __unique_ptr_release(mut repr: *mut c_void) -> *mut CxxVector<Self> { extern "C" { attr! { @@ -365,6 +380,7 @@ macro_rules! impl_vector_element { } __unique_ptr_release(&mut repr) } + #[doc(hidden)] unsafe fn __unique_ptr_drop(mut repr: *mut c_void) { extern "C" { attr! { diff --git a/src/shared_ptr.rs b/src/shared_ptr.rs index e7ae9974..66b988ba 100644 --- a/src/shared_ptr.rs +++ b/src/shared_ptr.rs @@ -204,9 +204,11 @@ pub unsafe trait SharedPtrTarget { macro_rules! impl_shared_ptr_target { ($segment:expr, $name:expr, $ty:ty) => { unsafe impl SharedPtrTarget for $ty { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result { f.write_str($name) } + #[doc(hidden)] unsafe fn __null(new: *mut c_void) { extern "C" { attr! { @@ -216,6 +218,7 @@ macro_rules! impl_shared_ptr_target { } __null(new); } + #[doc(hidden)] unsafe fn __new(value: Self, new: *mut c_void) { extern "C" { attr! { @@ -225,6 +228,7 @@ macro_rules! impl_shared_ptr_target { } __uninit(new).cast::<$ty>().write(value); } + #[doc(hidden)] unsafe fn __clone(this: *const c_void, new: *mut c_void) { extern "C" { attr! { @@ -234,6 +238,7 @@ macro_rules! impl_shared_ptr_target { } __clone(this, new); } + #[doc(hidden)] unsafe fn __get(this: *const c_void) -> *const Self { extern "C" { attr! { @@ -243,6 +248,7 @@ macro_rules! impl_shared_ptr_target { } __get(this).cast() } + #[doc(hidden)] unsafe fn __drop(this: *mut c_void) { extern "C" { attr! { diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs index bc326dce..836f4677 100644 --- a/src/unique_ptr.rs +++ b/src/unique_ptr.rs @@ -242,9 +242,11 @@ extern "C" { } unsafe impl UniquePtrTarget for CxxString { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result { f.write_str("CxxString") } + #[doc(hidden)] fn __null() -> *mut c_void { let mut repr = ptr::null_mut::<c_void>(); unsafe { @@ -252,17 +254,21 @@ unsafe impl UniquePtrTarget for CxxString { } repr } + #[doc(hidden)] unsafe fn __raw(raw: *mut Self) -> *mut c_void { let mut repr = ptr::null_mut::<c_void>(); unique_ptr_std_string_raw(&mut repr, raw); repr } + #[doc(hidden)] unsafe fn __get(repr: *mut c_void) -> *const Self { unique_ptr_std_string_get(&repr) } + #[doc(hidden)] unsafe fn __release(mut repr: *mut c_void) -> *mut Self { unique_ptr_std_string_release(&mut repr) } + #[doc(hidden)] unsafe fn __drop(mut repr: *mut c_void) { unique_ptr_std_string_drop(&mut repr); } @@ -272,21 +278,27 @@ unsafe impl<T> UniquePtrTarget for CxxVector<T> where T: VectorElement, { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result { write!(f, "CxxVector<{}>", display(T::__typename)) } + #[doc(hidden)] fn __null() -> *mut c_void { T::__unique_ptr_null() } + #[doc(hidden)] unsafe fn __raw(raw: *mut Self) -> *mut c_void { T::__unique_ptr_raw(raw) } + #[doc(hidden)] unsafe fn __get(repr: *mut c_void) -> *const Self { T::__unique_ptr_get(repr) } + #[doc(hidden)] unsafe fn __release(repr: *mut c_void) -> *mut Self { T::__unique_ptr_release(repr) } + #[doc(hidden)] unsafe fn __drop(repr: *mut c_void) { T::__unique_ptr_drop(repr); } diff --git a/src/weak_ptr.rs b/src/weak_ptr.rs index ba744618..8291d59b 100644 --- a/src/weak_ptr.rs +++ b/src/weak_ptr.rs @@ -111,9 +111,11 @@ pub unsafe trait WeakPtrTarget { macro_rules! impl_weak_ptr_target { ($segment:expr, $name:expr, $ty:ty) => { unsafe impl WeakPtrTarget for $ty { + #[doc(hidden)] fn __typename(f: &mut fmt::Formatter) -> fmt::Result { f.write_str($name) } + #[doc(hidden)] unsafe fn __null(new: *mut c_void) { extern "C" { attr! { @@ -123,6 +125,7 @@ macro_rules! impl_weak_ptr_target { } __null(new); } + #[doc(hidden)] unsafe fn __clone(this: *const c_void, new: *mut c_void) { extern "C" { attr! { @@ -132,6 +135,7 @@ macro_rules! impl_weak_ptr_target { } __clone(this, new); } + #[doc(hidden)] unsafe fn __downgrade(shared: *const c_void, weak: *mut c_void) { extern "C" { attr! { @@ -141,6 +145,7 @@ macro_rules! impl_weak_ptr_target { } __downgrade(shared, weak); } + #[doc(hidden)] unsafe fn __upgrade(weak: *const c_void, shared: *mut c_void) { extern "C" { attr! { @@ -150,6 +155,7 @@ macro_rules! impl_weak_ptr_target { } __upgrade(weak, shared); } + #[doc(hidden)] unsafe fn __drop(this: *mut c_void) { extern "C" { attr! { |