@@ -13,10 +13,9 @@ use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
13
13
use rustc:: hir:: map:: definitions:: DefPathData ;
14
14
use rustc:: hir:: { self , ImplPolarity } ;
15
15
use rustc:: traits:: {
16
- Clause , Clauses , DomainGoal , FromEnv , Goal , PolyDomainGoal , ProgramClause , WellFormed ,
17
- WhereClause ,
16
+ Clause , Clauses , DomainGoal , Goal , PolyDomainGoal , ProgramClause , WhereClauseAtom ,
18
17
} ;
19
- use rustc:: ty:: query :: Providers ;
18
+ use rustc:: ty:: subst :: Substs ;
20
19
use rustc:: ty:: { self , Slice , TyCtxt } ;
21
20
use rustc_data_structures:: fx:: FxHashSet ;
22
21
use std:: mem;
@@ -278,21 +277,15 @@ fn program_clauses_for_trait<'a, 'tcx>(
278
277
hypotheses,
279
278
} ) )
280
279
. 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) )
289
282
}
290
283
291
284
fn wellformed_from_bound < ' a , ' tcx > (
292
285
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
293
286
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 > > {
296
289
// Rule WellFormed-TraitRef
297
290
//
298
291
// For each where clause WC:
@@ -309,18 +302,17 @@ fn wellformed_from_bound<'a, 'tcx>(
309
302
. lower ( )
310
303
. map_bound ( |wc| wc. into_wellformed_goal ( ) ) ;
311
304
// 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) ) )
324
316
}
325
317
326
318
fn program_clauses_for_impl < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Clauses < ' tcx > {
0 commit comments