@@ -114,15 +114,16 @@ impl<'tcx> Lower<PolyDomainGoal<'tcx>> for ty::Predicate<'tcx> {
114114 }
115115}
116116
117- /// Used for lowered where clauses (see rustc guide).
117+ /// Used for implied bounds related rules (see rustc guide).
118118trait IntoFromEnvGoal {
119- // Transforms an existing goal into a FromEnv goal.
119+ /// Transforms an existing goal into a ` FromEnv` goal.
120120 fn into_from_env_goal ( self ) -> Self ;
121121}
122122
123+ /// Used for well-formedness related rules (see rustc guide).
123124trait IntoWellFormedGoal {
124- // Transforms an existing goal into a WellFormed goal.
125- fn into_wellformed_goal ( self ) -> Self ;
125+ /// Transforms an existing goal into a ` WellFormed` goal.
126+ fn into_well_formed_goal ( self ) -> Self ;
126127}
127128
128129impl < ' tcx > IntoFromEnvGoal for DomainGoal < ' tcx > {
@@ -139,7 +140,7 @@ impl<'tcx> IntoFromEnvGoal for DomainGoal<'tcx> {
139140}
140141
141142impl < ' tcx > IntoWellFormedGoal for DomainGoal < ' tcx > {
142- fn into_wellformed_goal ( self ) -> DomainGoal < ' tcx > {
143+ fn into_well_formed_goal ( self ) -> DomainGoal < ' tcx > {
143144 use self :: WhereClause :: * ;
144145
145146 match self {
@@ -284,34 +285,35 @@ fn program_clauses_for_trait<'a, 'tcx>(
284285
285286 // Rule WellFormed-TraitRef
286287 //
287- // For each where clause WC:
288+ // Here `WC` denotes the set of all where clauses:
289+ // ```
288290 // forall<Self, P1..Pn> {
289291 // WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
290292 // }
293+ // ```
291294
292- //Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
293- let mut extend_where_clauses = vec ! [ ty:: Binder :: dummy( trait_pred. lower( ) ) ] ;
294- extend_where_clauses. extend (
295- where_clauses
296- . into_iter ( )
297- . map ( |wc| wc. lower ( ) . map_bound ( |wc| wc. into_wellformed_goal ( ) ) ) ,
298- ) ;
295+ // `Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)`
296+ let wf_conditions = iter:: once ( ty:: Binder :: dummy ( trait_pred. lower ( ) ) )
297+ . chain (
298+ where_clauses
299+ . into_iter ( )
300+ . map ( |wc| wc. lower ( ) )
301+ . map ( |wc| wc. map_bound ( |goal| goal. into_well_formed_goal ( ) ) )
302+ ) ;
299303
300- // WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
301- let clause = ProgramClause {
304+ // ` WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)`
305+ let wf_clause = ProgramClause {
302306 goal : DomainGoal :: WellFormed ( WellFormed :: Trait ( trait_pred) ) ,
303307 hypotheses : tcx. mk_goals (
304- extend_where_clauses
305- . into_iter ( )
306- . map ( |wc| Goal :: from_poly_domain_goal ( wc, tcx) ) ,
308+ wf_conditions. map ( |wc| Goal :: from_poly_domain_goal ( wc, tcx) ) ,
307309 ) ,
308310 } ;
309- let wellformed_clauses = iter:: once ( Clause :: ForAll ( ty:: Binder :: dummy ( clause ) ) ) ;
311+ let wf_clause = iter:: once ( Clause :: ForAll ( ty:: Binder :: dummy ( wf_clause ) ) ) ;
310312
311313 tcx. mk_clauses (
312314 clauses
313315 . chain ( implied_bound_clauses)
314- . chain ( wellformed_clauses ) ,
316+ . chain ( wf_clause )
315317 )
316318}
317319
0 commit comments