@@ -129,7 +129,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
129
129
fn select (
130
130
& mut self ,
131
131
selcx : & mut SelectionContext < ' a , ' tcx > ,
132
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
132
+ ) -> Vec < FulfillmentError < ' tcx > > {
133
133
let span = debug_span ! ( "select" , obligation_forest_size = ?self . predicates. len( ) ) ;
134
134
let _enter = span. enter ( ) ;
135
135
@@ -163,7 +163,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
163
163
errors. len( )
164
164
) ;
165
165
166
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors ) }
166
+ errors
167
167
}
168
168
}
169
169
@@ -226,38 +226,46 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
226
226
fn select_all_or_error (
227
227
& mut self ,
228
228
infcx : & InferCtxt < ' _ , ' tcx > ,
229
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
230
- self . select_where_possible ( infcx) ?;
229
+ ) -> Vec < FulfillmentError < ' tcx > > {
230
+ {
231
+ let errors = self . select_where_possible ( infcx) ;
232
+ if !errors. is_empty ( ) {
233
+ return errors;
234
+ }
235
+ }
231
236
232
- let errors : Vec < _ > = self
237
+ self
233
238
. predicates
234
239
. to_errors ( CodeAmbiguity )
235
240
. into_iter ( )
236
241
. map ( to_fulfillment_error)
237
- . collect ( ) ;
238
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
242
+ . collect ( )
239
243
}
240
244
241
245
fn select_all_with_constness_or_error (
242
246
& mut self ,
243
247
infcx : & InferCtxt < ' _ , ' tcx > ,
244
248
constness : rustc_hir:: Constness ,
245
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
246
- self . select_with_constness_where_possible ( infcx, constness) ?;
249
+ ) -> Vec < FulfillmentError < ' tcx > > {
250
+ {
251
+ let errors = self . select_with_constness_where_possible ( infcx, constness) ;
252
+ if !errors. is_empty ( ) {
253
+ return errors;
254
+ }
255
+ }
247
256
248
- let errors : Vec < _ > = self
257
+ self
249
258
. predicates
250
259
. to_errors ( CodeAmbiguity )
251
260
. into_iter ( )
252
261
. map ( to_fulfillment_error)
253
- . collect ( ) ;
254
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
262
+ . collect ( )
255
263
}
256
264
257
265
fn select_where_possible (
258
266
& mut self ,
259
267
infcx : & InferCtxt < ' _ , ' tcx > ,
260
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
268
+ ) -> Vec < FulfillmentError < ' tcx > > {
261
269
let mut selcx = SelectionContext :: new ( infcx) ;
262
270
self . select ( & mut selcx)
263
271
}
@@ -266,7 +274,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
266
274
& mut self ,
267
275
infcx : & InferCtxt < ' _ , ' tcx > ,
268
276
constness : hir:: Constness ,
269
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
277
+ ) -> Vec < FulfillmentError < ' tcx > > {
270
278
let mut selcx = SelectionContext :: with_constness ( infcx, constness) ;
271
279
self . select ( & mut selcx)
272
280
}
0 commit comments