@@ -240,23 +240,24 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
240
240
let mut impl_candidates = Vec :: new ( ) ;
241
241
let trait_def = infcx. tcx . lookup_trait_def ( trait_ref. def_id ( ) ) ;
242
242
243
- trait_def . for_each_impl ( infcx . tcx , |def_id| {
244
- let imp = infcx. tcx . impl_trait_ref ( def_id) . unwrap ( ) ;
245
- if let Some ( simp ) = simp {
243
+ match simp {
244
+ Some ( simp ) => trait_def . for_each_impl ( infcx. tcx , | def_id| {
245
+ let imp = infcx . tcx . impl_trait_ref ( def_id ) . unwrap ( ) ;
246
246
let imp_simp = fast_reject:: simplify_type ( infcx. tcx ,
247
247
imp. self_ty ( ) ,
248
248
true ) ;
249
249
if let Some ( imp_simp) = imp_simp {
250
- if simp = = imp_simp {
251
- impl_candidates . push ( imp ) ;
250
+ if simp ! = imp_simp {
251
+ return ;
252
252
}
253
- } else {
254
- impl_candidates. push ( imp) ;
255
253
}
256
- } else {
257
254
impl_candidates. push ( imp) ;
258
- }
259
- } ) ;
255
+ } ) ,
256
+ None => trait_def. for_each_impl ( infcx. tcx , |def_id| {
257
+ impl_candidates. push (
258
+ infcx. tcx . impl_trait_ref ( def_id) . unwrap ( ) ) ;
259
+ } )
260
+ } ;
260
261
261
262
if impl_candidates. len ( ) > 0 {
262
263
err. fileline_help (
@@ -266,7 +267,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
266
267
let end = cmp:: min ( 4 , impl_candidates. len ( ) ) ;
267
268
for candidate in & impl_candidates[ 0 ..end] {
268
269
err. fileline_help ( obligation. cause . span ,
269
- candidate) ;
270
+ & format ! ( " {:?}" , candidate) ) ;
270
271
}
271
272
if impl_candidates. len ( ) > 4 {
272
273
err. fileline_help ( obligation. cause . span ,
0 commit comments