@@ -13,10 +13,9 @@ use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
1313use rustc:: hir:: map:: definitions:: DefPathData ;
1414use rustc:: hir:: { self , ImplPolarity } ;
1515use rustc:: traits:: {
16- Clause , Clauses , DomainGoal , FromEnv , Goal , PolyDomainGoal , ProgramClause , WellFormed ,
17- WhereClause ,
16+ Clause , Clauses , DomainGoal , Goal , PolyDomainGoal , ProgramClause , WhereClauseAtom ,
1817} ;
19- use rustc:: ty:: query :: Providers ;
18+ use rustc:: ty:: subst :: Substs ;
2019use rustc:: ty:: { self , Slice , TyCtxt } ;
2120use rustc_data_structures:: fx:: FxHashSet ;
2221use std:: mem;
@@ -278,21 +277,15 @@ fn program_clauses_for_trait<'a, 'tcx>(
278277 hypotheses,
279278 } ) )
280279 . map ( |wc| implied_bound_from_trait ( tcx, trait_pred, wc) ) ;
281- let wellformed_clauses = where_clauses[ 1 ..]
282- . into_iter ( )
283- . map ( |wc| wellformed_from_bound ( tcx, trait_pred, wc) ) ;
284- tcx. mk_clauses (
285- clauses
286- . chain ( implied_bound_clauses)
287- . chain ( wellformed_clauses) ,
288- )
280+ let wellformed_clauses = wellformed_from_bound ( tcx, trait_pred, & where_clauses[ 1 ..] ) ;
281+ tcx. mk_clauses ( clauses. chain ( implied_bound_clauses) . chain ( wellformed_clauses) )
289282}
290283
291284fn wellformed_from_bound < ' a , ' tcx > (
292285 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
293286 trait_pred : ty:: TraitPredicate < ' tcx > ,
294- where_clause : & ty:: Predicate < ' tcx > ,
295- ) -> Clause < ' tcx > {
287+ where_clauses : & [ ty:: Predicate < ' tcx > ] ,
288+ ) -> iter :: Once < Clause < ' tcx > > {
296289 // Rule WellFormed-TraitRef
297290 //
298291 // For each where clause WC:
@@ -309,18 +302,17 @@ fn wellformed_from_bound<'a, 'tcx>(
309302 . lower ( )
310303 . map_bound ( |wc| wc. into_wellformed_goal ( ) ) ;
311304 // Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
312- let mut where_clauses = vec ! [ impl_trait] ;
313- where_clauses. push ( wellformed_wc) ;
314- Clause :: ForAll ( where_clause. lower ( ) . map_bound ( |_| {
315- ProgramClause {
316- goal : wellformed_trait,
317- hypotheses : tcx. mk_goals (
318- where_clauses
319- . into_iter ( )
320- . map ( |wc| Goal :: from_poly_domain_goal ( wc, tcx) ) ,
321- ) ,
322- }
323- } ) )
305+ let mut wcs = vec ! [ impl_trait] ;
306+ wcs. extend ( wellformed_wcs) ;
307+
308+ let clause = ProgramClause {
309+ goal : wellformed_trait,
310+ hypotheses : tcx. mk_goals (
311+ wcs. into_iter ( )
312+ . map ( |wc| Goal :: from_poly_domain_goal ( wc, tcx) ) ,
313+ ) ,
314+ } ;
315+ iter:: once ( Clause :: ForAll ( ty:: Binder :: dummy ( clause) ) )
324316}
325317
326318fn program_clauses_for_impl < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Clauses < ' tcx > {
0 commit comments