Put doc cfg on extra-traits impls

This commit is contained in:
David Tolnay 2020-11-21 13:38:24 -08:00
parent 82777db3db
commit 99be3074d1
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
11 changed files with 746 additions and 0 deletions

View File

@ -81,6 +81,7 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
quote! {
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for #ident {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
#body

View File

@ -113,6 +113,7 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
let eq = quote! {
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Eq for #ident {}
};
@ -132,6 +133,7 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
#eq
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl PartialEq for #ident {
fn eq(&self, #other: &Self) -> bool {
#body

View File

@ -131,6 +131,7 @@ fn expand_impl(defs: &Definitions, node: &Node) -> TokenStream {
quote! {
#cfg_features
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Hash for #ident {
fn hash<H>(&self, #state: &mut H)
where

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -375,6 +375,7 @@ macro_rules! generics_wrapper_impls {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<'a> Debug for $ty<'a> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -385,9 +386,11 @@ macro_rules! generics_wrapper_impls {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<'a> Eq for $ty<'a> {}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<'a> PartialEq for $ty<'a> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
@ -395,6 +398,7 @@ macro_rules! generics_wrapper_impls {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<'a> Hash for $ty<'a> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.hash(state);

View File

@ -513,6 +513,7 @@ mod debug_impls {
use super::*;
use std::fmt::{self, Debug};
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitStr {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -522,6 +523,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitByteStr {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -531,6 +533,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitByte {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -540,6 +543,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitChar {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -549,6 +553,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitInt {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -558,6 +563,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitFloat {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -567,6 +573,7 @@ mod debug_impls {
}
}
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for LitBool {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter
@ -625,6 +632,7 @@ macro_rules! lit_extra_traits {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl PartialEq for $ty {
fn eq(&self, other: &Self) -> bool {
self.repr.token.to_string() == other.repr.token.to_string()
@ -632,6 +640,7 @@ macro_rules! lit_extra_traits {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Hash for $ty {
fn hash<H>(&self, state: &mut H)
where

View File

@ -361,6 +361,7 @@ where
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<T, P> Eq for Punctuated<T, P>
where
T: Eq,
@ -369,6 +370,7 @@ where
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<T, P> PartialEq for Punctuated<T, P>
where
T: PartialEq,
@ -381,6 +383,7 @@ where
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<T, P> Hash for Punctuated<T, P>
where
T: Hash,
@ -394,6 +397,7 @@ where
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl<T: Debug, P: Debug> Debug for Punctuated<T, P> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut list = f.debug_list();

View File

@ -36,6 +36,7 @@ impl Clone for Reserved {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for Reserved {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.debug_struct("Reserved").finish()

View File

@ -280,6 +280,7 @@ macro_rules! define_keywords {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(stringify!($name))
@ -287,9 +288,11 @@ macro_rules! define_keywords {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl cmp::Eq for $name {}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl PartialEq for $name {
fn eq(&self, _other: &$name) -> bool {
true
@ -297,6 +300,7 @@ macro_rules! define_keywords {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Hash for $name {
fn hash<H: Hasher>(&self, _state: &mut H) {}
}
@ -399,6 +403,7 @@ macro_rules! define_punctuation_structs {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(stringify!($name))
@ -406,9 +411,11 @@ macro_rules! define_punctuation_structs {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl cmp::Eq for $name {}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl PartialEq for $name {
fn eq(&self, _other: &$name) -> bool {
true
@ -416,6 +423,7 @@ macro_rules! define_punctuation_structs {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Hash for $name {
fn hash<H: Hasher>(&self, _state: &mut H) {}
}
@ -504,6 +512,7 @@ macro_rules! define_delimiters {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Debug for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(stringify!($name))
@ -511,9 +520,11 @@ macro_rules! define_delimiters {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl cmp::Eq for $name {}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl PartialEq for $name {
fn eq(&self, _other: &$name) -> bool {
true
@ -521,6 +532,7 @@ macro_rules! define_delimiters {
}
#[cfg(feature = "extra-traits")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))]
impl Hash for $name {
fn hash<H: Hasher>(&self, _state: &mut H) {}
}