@@ -225,36 +225,6 @@ impl<DB: Backend> QueryFragment<DB> for LeftOuter {
225225 }
226226}
227227
228- impl < T , From > JoinTo < SelectStatement < From > > for T where
229- T : Table + JoinTo < From > ,
230- {
231- type JoinOnClause = T :: JoinOnClause ;
232-
233- fn join_on_clause ( ) -> Self :: JoinOnClause {
234- T :: join_on_clause ( )
235- }
236- }
237-
238- impl < T , Join , On > JoinTo < JoinOn < Join , On > > for T where
239- T : Table + JoinTo < Join > ,
240- {
241- type JoinOnClause = T :: JoinOnClause ;
242-
243- fn join_on_clause ( ) -> Self :: JoinOnClause {
244- T :: join_on_clause ( )
245- }
246- }
247-
248- impl < Left , Mid , Right , Kind > JoinTo < Join < Mid , Right , Kind > > for Left where
249- Left : Table + JoinTo < Mid > ,
250- {
251- type JoinOnClause = Left :: JoinOnClause ;
252-
253- fn join_on_clause ( ) -> Self :: JoinOnClause {
254- Left :: join_on_clause ( )
255- }
256- }
257-
258228impl < Left , Mid , Right , Kind > JoinTo < Right > for Join < Left , Mid , Kind > where
259229 Left : JoinTo < Right > ,
260230{
@@ -275,7 +245,6 @@ impl<Join, On, Right> JoinTo<Right> for JoinOn<Join, On> where
275245 }
276246}
277247
278-
279248use super :: { Succ , Never , AppearsInFromClause } ;
280249
281250impl < T , Left , Right , Kind > AppearsInFromClause < T > for Join < Left , Right , Kind > where
@@ -292,6 +261,22 @@ impl<T, Join, On> AppearsInFromClause<T> for JoinOn<Join, On> where
292261 type Count = Join :: Count ;
293262}
294263
264+ #[ allow( missing_debug_implementations, missing_copy_implementations) ]
265+ #[ doc( hidden) ]
266+ /// A hack to allow bidirectional joins to be generated from `#[belongs_to]`
267+ ///
268+ /// This type needs to exist because it is illegal in Rust today to write
269+ /// `impl JoinTo<posts> for <User as HasTable>::Table`, even though the type
270+ /// is fully monomorphic and projects to a local type. If this restriction
271+ /// were ever lifted in the future, this type could be removed.
272+ ///
273+ /// Instead, after generating `impl JoinTo<<User as HasTable>::Table> for
274+ /// posts`, we *also* generate `impl JoinTo<PleaseGenerateInverseJoinImpls<<User
275+ /// as HasTable>::table> for posts`, and rely on the fact that `users::table`
276+ /// will have a blanket impl on itself for anything that joins to
277+ /// `PleaseGenerateInverseJoinImpls`.
278+ pub struct PleaseGenerateInverseJoinImpls < T > ( T ) ;
279+
295280pub trait Plus < T > {
296281 type Output ;
297282}
0 commit comments