@@ -161,48 +161,60 @@ impl<'a> fmt::Display for WhereClause<'a> {
161
161
if gens. where_predicates . is_empty ( ) {
162
162
return Ok ( ( ) ) ;
163
163
}
164
+ let mut clause = String :: new ( ) ;
164
165
if f. alternate ( ) {
165
- f . write_str ( " " ) ? ;
166
+ clause . push_str ( " where " ) ;
166
167
} else {
167
- f . write_str ( " <span class='where'>where " ) ? ;
168
+ clause . push_str ( " <span class='where'>where " ) ;
168
169
}
169
170
for ( i, pred) in gens. where_predicates . iter ( ) . enumerate ( ) {
170
171
if i > 0 {
171
- f. write_str ( ", " ) ?;
172
+ if f. alternate ( ) {
173
+ clause. push_str ( ", " ) ;
174
+ } else {
175
+ clause. push_str ( ",<br>" ) ;
176
+ }
172
177
}
173
178
match pred {
174
179
& clean:: WherePredicate :: BoundPredicate { ref ty, ref bounds } => {
175
180
let bounds = bounds;
176
181
if f. alternate ( ) {
177
- write ! ( f , "{:#}: {:#}" , ty, TyParamBounds ( bounds) ) ? ;
182
+ clause . push_str ( & format ! ( "{:#}: {:#}" , ty, TyParamBounds ( bounds) ) ) ;
178
183
} else {
179
- write ! ( f , "{}: {}" , ty, TyParamBounds ( bounds) ) ? ;
184
+ clause . push_str ( & format ! ( "{}: {}" , ty, TyParamBounds ( bounds) ) ) ;
180
185
}
181
186
}
182
187
& clean:: WherePredicate :: RegionPredicate { ref lifetime,
183
188
ref bounds } => {
184
- write ! ( f , "{}: " , lifetime) ? ;
189
+ clause . push_str ( & format ! ( "{}: " , lifetime) ) ;
185
190
for ( i, lifetime) in bounds. iter ( ) . enumerate ( ) {
186
191
if i > 0 {
187
- f . write_str ( " + " ) ? ;
192
+ clause . push_str ( " + " ) ;
188
193
}
189
194
190
- write ! ( f , "{}" , lifetime) ? ;
195
+ clause . push_str ( & format ! ( "{}" , lifetime) ) ;
191
196
}
192
197
}
193
198
& clean:: WherePredicate :: EqPredicate { ref lhs, ref rhs } => {
194
199
if f. alternate ( ) {
195
- write ! ( f , "{:#} == {:#}" , lhs, rhs) ? ;
200
+ clause . push_str ( & format ! ( "{:#} == {:#}" , lhs, rhs) ) ;
196
201
} else {
197
- write ! ( f , "{} == {}" , lhs, rhs) ? ;
202
+ clause . push_str ( & format ! ( "{} == {}" , lhs, rhs) ) ;
198
203
}
199
204
}
200
205
}
201
206
}
202
207
if !f. alternate ( ) {
203
208
f. write_str ( "</span>" ) ?;
209
+ let plain = format ! ( "{:#}" , self ) ;
210
+ if plain. len ( ) > 80 {
211
+ let padding = repeat ( " " ) . take ( 8 ) . collect :: < String > ( ) ;
212
+ clause = clause. replace ( "<br>" , & format ! ( "<br>{}" , padding) ) ;
213
+ } else {
214
+ clause = clause. replace ( "<br>" , " " ) ;
215
+ }
204
216
}
205
- Ok ( ( ) )
217
+ write ! ( f , "{}" , clause )
206
218
}
207
219
}
208
220
0 commit comments