@@ -135,10 +135,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
135
135
) ;
136
136
137
137
// Select everything, returning errors.
138
- let true_errors = match fulfill_cx. select_where_possible ( self ) {
139
- Ok ( ( ) ) => vec ! [ ] ,
140
- Err ( errors) => errors,
141
- } ;
138
+ let true_errors = fulfill_cx. select_where_possible ( self ) . err ( ) . unwrap_or_else ( Vec :: new) ;
142
139
debug ! ( "true_errors = {:#?}" , true_errors) ;
143
140
144
141
if !true_errors. is_empty ( ) {
@@ -148,10 +145,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
148
145
}
149
146
150
147
// Anything left unselected *now* must be an ambiguity.
151
- let ambig_errors = match fulfill_cx. select_all_or_error ( self ) {
152
- Ok ( ( ) ) => vec ! [ ] ,
153
- Err ( errors) => errors,
154
- } ;
148
+ let ambig_errors = fulfill_cx. select_all_or_error ( self ) . err ( ) . unwrap_or_else ( Vec :: new) ;
155
149
debug ! ( "ambig_errors = {:#?}" , ambig_errors) ;
156
150
157
151
let region_obligations = self . take_registered_region_obligations ( ) ;
@@ -448,10 +442,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
448
442
. variables
449
443
. iter ( )
450
444
. enumerate ( )
451
- . map ( |( index, info) | match opt_values[ CanonicalVar :: new ( index) ] {
452
- Some ( k) => k,
453
- None => self . fresh_inference_var_for_canonical_var ( cause. span , * info) ,
454
- } )
445
+ . map ( |( index, info) | opt_values[ CanonicalVar :: new ( index) ] . unwrap_or_else ( ||
446
+ self . fresh_inference_var_for_canonical_var ( cause. span , * info)
447
+ ) )
455
448
. collect ( ) ,
456
449
} ;
457
450
0 commit comments