Skip to content

Commit

Permalink
Hide Id associated types from ExternType impl rustdocs
Browse files Browse the repository at this point in the history
This eliminates a quite large amount of unhelpful noise from https://docs.rs/cxx/1/cxx/trait.ExternType.html.
  • Loading branch information
dtolnay committed Feb 16, 2021
1 parent efd852d commit 6e3a863
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions macro/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fn expand_struct(strct: &Struct) -> TokenStream {
#struct_def

unsafe impl #generics ::cxx::ExternType for #ident #generics {
#[doc(hidden)]
type Id = #type_id;
type Kind = ::cxx::kind::Trivial;
}
Expand Down Expand Up @@ -330,6 +331,7 @@ fn expand_enum(enm: &Enum) -> TokenStream {
}

unsafe impl ::cxx::ExternType for #ident {
#[doc(hidden)]
type Id = #type_id;
type Kind = ::cxx::kind::Trivial;
}
Expand Down Expand Up @@ -370,6 +372,7 @@ fn expand_cxx_type(ety: &ExternType) -> TokenStream {
#extern_type_def

unsafe impl #generics ::cxx::ExternType for #ident #generics {
#[doc(hidden)]
type Id = #type_id;
type Kind = ::cxx::kind::Opaque;
}
Expand Down Expand Up @@ -739,6 +742,7 @@ fn expand_rust_type_impl(ety: &ExternType) -> TokenStream {
let span = derive.span;
impls.extend(quote_spanned! {span=>
unsafe impl #generics ::cxx::ExternType for #ident #generics {
#[doc(hidden)]
type Id = #type_id;
type Kind = ::cxx::kind::Opaque;
}
Expand Down
1 change: 1 addition & 0 deletions src/extern_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ macro_rules! impl_extern_type {
($([$kind:ident] $($ty:path = $cxxpath:literal)*)*) => {
$($(
unsafe impl ExternType for $ty {
#[doc(hidden)]
type Id = crate::type_id!($cxxpath);
type Kind = $kind;
}
Expand Down

0 comments on commit 6e3a863

Please sign in to comment.