Put doc cfg on Clone impls

This commit is contained in:
David Tolnay 2020-11-21 13:34:52 -08:00
parent e1b2e9fc44
commit 82777db3db
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
7 changed files with 200 additions and 0 deletions

View File

@ -82,8 +82,10 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
if copy {
return quote! {
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Copy for #ident {}
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for #ident {
fn clone(&self) -> Self {
*self
@ -96,6 +98,7 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
quote! {
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for #ident {
fn clone(&self) -> Self {
#body

File diff suppressed because it is too large Load Diff

View File

@ -367,6 +367,7 @@ impl Generics {
macro_rules! generics_wrapper_impls {
($ty:ident) => {
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl<'a> Clone for $ty<'a> {
fn clone(&self) -> Self {
$ty(self.0)

View File

@ -578,6 +578,7 @@ mod debug_impls {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for LitRepr {
fn clone(&self) -> Self {
LitRepr {
@ -588,6 +589,7 @@ impl Clone for LitRepr {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for LitIntRepr {
fn clone(&self) -> Self {
LitIntRepr {
@ -599,6 +601,7 @@ impl Clone for LitIntRepr {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for LitFloatRepr {
fn clone(&self) -> Self {
LitFloatRepr {
@ -612,6 +615,7 @@ impl Clone for LitFloatRepr {
macro_rules! lit_extra_traits {
($ty:ident) => {
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for $ty {
fn clone(&self) -> Self {
$ty {

View File

@ -346,6 +346,7 @@ impl<T, P> Punctuated<T, P> {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl<T, P> Clone for Punctuated<T, P>
where
T: Clone,
@ -932,6 +933,7 @@ impl<T, P> Pair<T, P> {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl<T, P> Clone for Pair<T, P>
where
T: Clone,

View File

@ -26,6 +26,7 @@ impl Default for Reserved {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for Reserved {
fn clone(&self) -> Self {
Reserved {

View File

@ -268,9 +268,11 @@ macro_rules! define_keywords {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Copy for $name {}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for $name {
fn clone(&self) -> Self {
*self
@ -385,9 +387,11 @@ macro_rules! define_punctuation_structs {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Copy for $name {}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for $name {
fn clone(&self) -> Self {
*self
@ -488,9 +492,11 @@ macro_rules! define_delimiters {
}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Copy for $name {}
#[cfg(feature = "clone-impls")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))]
impl Clone for $name {
fn clone(&self) -> Self {
*self