Skip to content

Commit

Permalink
Fix #2480
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weiznich committed Aug 15, 2020
1 parent 4e69728 commit 4db0e1d
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions diesel/src/type_impls/tuples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,) => {
Expand Down

0 comments on commit 4db0e1d

Please sign in to comment.