From 4db0e1d75f2fcfdecc733c3979ffd499cd1fa403 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 15 Aug 2020 14:06:37 +0200 Subject: [PATCH] Fix #2480 This commit replaces the recursive trait bounds on our SqlType impls for tuples with explicit bounds for all tuple sizes. This reduces the compile time for the 32-column feature for me from 17mins to ~40s. --- diesel/src/type_impls/tuples.rs | 44 ++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/diesel/src/type_impls/tuples.rs b/diesel/src/type_impls/tuples.rs index e97ab157b85c..edf313025d12 100644 --- a/diesel/src/type_impls/tuples.rs +++ b/diesel/src/type_impls/tuples.rs @@ -395,13 +395,45 @@ macro_rules! impl_from_sql_row { } macro_rules! impl_sql_type { - ($T1: ident, $($T: ident,)+) => { - impl<$T1, $($T,)+> SqlType for ($T1, $($T,)*) - where $T1: SqlType, - ($($T,)*): SqlType, - $T1::IsNull: OneIsNullable<<($($T,)*) as SqlType>::IsNull>, + ( + @build + start_ts = [$($ST: ident,)*], + ts = [$T1: ident,], + bounds = [$($bounds: tt)*], + is_null = [$($is_null: tt)*], + )=> { + impl<$($ST,)*> SqlType for ($($ST,)*) + where + $($ST: SqlType,)* + $($bounds)* + $T1::IsNull: OneIsNullable<$($is_null)*>, { - type IsNull = <$T1::IsNull as OneIsNullable<<($($T,)*) as SqlType>::IsNull>>::Out; + type IsNull = <$T1::IsNull as OneIsNullable<$($is_null)*>>::Out; + } + + }; + ( + @build + start_ts = [$($ST: ident,)*], + ts = [$T1: ident, $($T: ident,)+], + bounds = [$($bounds: tt)*], + is_null = [$($is_null: tt)*], + )=> { + impl_sql_type!{ + @build + start_ts = [$($ST,)*], + ts = [$($T,)*], + bounds = [$($bounds)* $T1::IsNull: OneIsNullable<$($is_null)*>,], + is_null = [<$T1::IsNull as OneIsNullable<$($is_null)*>>::Out], + } + }; + ($T1: ident, $($T: ident,)+) => { + impl_sql_type!{ + @build + start_ts = [$T1, $($T,)*], + ts = [$($T,)*], + bounds = [], + is_null = [$T1::IsNull], } }; ($T1: ident,) => {