mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Put doc cfg on extra-traits impls
This commit is contained in:
parent
82777db3db
commit
99be3074d1
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
178
src/gen/debug.rs
178
src/gen/debug.rs
File diff suppressed because it is too large
Load Diff
358
src/gen/eq.rs
358
src/gen/eq.rs
File diff suppressed because it is too large
Load Diff
176
src/gen/hash.rs
176
src/gen/hash.rs
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
|
12
src/token.rs
12
src/token.rs
@ -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) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user