From 64b0dc8d0d5fa6b3bf996c60fdff054944f1c993 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 10 Aug 2024 22:01:28 -0700 Subject: [PATCH] Combine Generics impl blocks into one --- src/generics.rs | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/generics.rs b/src/generics.rs index f0ebd7fe2..119ed86d0 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -248,34 +248,7 @@ impl Generics { predicates: Punctuated::new(), }) } -} - -/// Returned by `Generics::split_for_impl`. -#[cfg(feature = "printing")] -#[cfg_attr( - docsrs, - doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) -)] -pub struct ImplGenerics<'a>(&'a Generics); - -/// Returned by `Generics::split_for_impl`. -#[cfg(feature = "printing")] -#[cfg_attr( - docsrs, - doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) -)] -pub struct TypeGenerics<'a>(&'a Generics); -/// Returned by `TypeGenerics::as_turbofish`. -#[cfg(feature = "printing")] -#[cfg_attr( - docsrs, - doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) -)] -pub struct Turbofish<'a>(&'a Generics); - -#[cfg(feature = "printing")] -impl Generics { /// Split a type's generics into the pieces required for impl'ing a trait /// for that type. /// @@ -294,6 +267,7 @@ impl Generics { /// } /// # ; /// ``` + #[cfg(feature = "printing")] #[cfg_attr( docsrs, doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) @@ -307,6 +281,30 @@ impl Generics { } } +/// Returned by `Generics::split_for_impl`. +#[cfg(feature = "printing")] +#[cfg_attr( + docsrs, + doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) +)] +pub struct ImplGenerics<'a>(&'a Generics); + +/// Returned by `Generics::split_for_impl`. +#[cfg(feature = "printing")] +#[cfg_attr( + docsrs, + doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) +)] +pub struct TypeGenerics<'a>(&'a Generics); + +/// Returned by `TypeGenerics::as_turbofish`. +#[cfg(feature = "printing")] +#[cfg_attr( + docsrs, + doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) +)] +pub struct Turbofish<'a>(&'a Generics); + #[cfg(feature = "printing")] macro_rules! generics_wrapper_impls { ($ty:ident) => {