From 3f37543794e5d43952399847a2ecbc1eb39f609f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 15:43:58 -0700 Subject: [PATCH 1/2] Implement Copy for syn::parse::Nothing --- src/parse.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/parse.rs b/src/parse.rs index 8668e0e1b7..a3b2f18e77 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1354,6 +1354,18 @@ impl Parse for Nothing { } } +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for Nothing { + fn clone(&self) -> Self { + *self + } +} + +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Copy for Nothing {} + #[cfg(feature = "extra-traits")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Nothing { From 4f6c0528d63874495ce23d197a898cd63cb04d60 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 16 Mar 2024 15:45:11 -0700 Subject: [PATCH 2/2] Implement ToTokens for syn::parse::Nothing --- src/parse.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/parse.rs b/src/parse.rs index a3b2f18e77..aafc1a9649 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -188,6 +188,8 @@ use crate::lookahead; use crate::punctuated::Punctuated; use crate::token::Token; use proc_macro2::{Delimiter, Group, Literal, Punct, Span, TokenStream, TokenTree}; +#[cfg(feature = "printing")] +use quote::ToTokens; use std::cell::Cell; use std::fmt::{self, Debug, Display}; #[cfg(feature = "extra-traits")] @@ -1354,6 +1356,14 @@ impl Parse for Nothing { } } +#[cfg(feature = "printing")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] +impl ToTokens for Nothing { + fn to_tokens(&self, tokens: &mut TokenStream) { + let _ = tokens; + } +} + #[cfg(feature = "clone-impls")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for Nothing {