forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#105081 - weiznich:regression_test_for_10432…
…2, r=compiler-errors Add a regression test for rust-lang#104322 r? `@compiler-errors`
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// build-pass | ||
// | ||
// Tests that overflows do not occur in certain situations | ||
// related to generic diesel code | ||
|
||
use mini_diesel::*; | ||
|
||
pub trait HandleDelete<K> {} | ||
|
||
pub fn handle_delete<D, R>() | ||
where | ||
R: HasTable, | ||
R::Table: HandleDelete<D> + 'static, | ||
{ | ||
} | ||
|
||
impl<K, T> HandleDelete<K> for T | ||
where | ||
T: Table + HasTable<Table = T> + 'static, | ||
K: 'static, | ||
&'static K: Identifiable<Table = T>, | ||
T::PrimaryKey: EqAll<<&'static K as Identifiable>::Id>, | ||
T::Query: FilterDsl<<T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>, | ||
Filter<T::Query, <T::PrimaryKey as EqAll<<&'static K as Identifiable>::Id>>::Output>: | ||
IntoUpdateTarget<Table = T>, | ||
{ | ||
} | ||
|
||
mod mini_diesel { | ||
pub trait HasTable { | ||
type Table: Table; | ||
} | ||
|
||
pub trait Identifiable: HasTable { | ||
type Id; | ||
} | ||
|
||
pub trait EqAll<Rhs> { | ||
type Output; | ||
} | ||
|
||
pub trait IntoUpdateTarget: HasTable { | ||
type WhereClause; | ||
} | ||
|
||
pub trait Query { | ||
type SqlType; | ||
} | ||
|
||
pub trait AsQuery { | ||
type Query: Query; | ||
} | ||
impl<T: Query> AsQuery for T { | ||
type Query = Self; | ||
} | ||
|
||
pub trait FilterDsl<Predicate> { | ||
type Output; | ||
} | ||
|
||
impl<T, Predicate> FilterDsl<Predicate> for T | ||
where | ||
T: Table, | ||
T::Query: FilterDsl<Predicate>, | ||
{ | ||
type Output = Filter<T::Query, Predicate>; | ||
} | ||
|
||
pub trait QuerySource { | ||
type FromClause; | ||
} | ||
|
||
pub trait Table: QuerySource + AsQuery + Sized { | ||
type PrimaryKey; | ||
} | ||
|
||
pub type Filter<Source, Predicate> = <Source as FilterDsl<Predicate>>::Output; | ||
} | ||
|
||
fn main() {} |