@@ -126,10 +126,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
126
126
}
127
127
128
128
/// Attempts to select obligations using `selcx`.
129
- fn select (
130
- & mut self ,
131
- selcx : & mut SelectionContext < ' a , ' tcx > ,
132
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
129
+ fn select ( & mut self , selcx : & mut SelectionContext < ' a , ' tcx > ) -> Vec < FulfillmentError < ' tcx > > {
133
130
let span = debug_span ! ( "select" , obligation_forest_size = ?self . predicates. len( ) ) ;
134
131
let _enter = span. enter ( ) ;
135
132
@@ -163,7 +160,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
163
160
errors. len( )
164
161
) ;
165
162
166
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors ) }
163
+ errors
167
164
}
168
165
}
169
166
@@ -223,41 +220,36 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
223
220
. register_obligation ( PendingPredicateObligation { obligation, stalled_on : vec ! [ ] } ) ;
224
221
}
225
222
226
- fn select_all_or_error (
227
- & mut self ,
228
- infcx : & InferCtxt < ' _ , ' tcx > ,
229
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
230
- self . select_where_possible ( infcx) ?;
231
-
232
- let errors: Vec < _ > = self
233
- . predicates
234
- . to_errors ( CodeAmbiguity )
235
- . into_iter ( )
236
- . map ( to_fulfillment_error)
237
- . collect ( ) ;
238
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
223
+ fn select_all_or_error ( & mut self , infcx : & InferCtxt < ' _ , ' tcx > ) -> Vec < FulfillmentError < ' tcx > > {
224
+ {
225
+ let errors = self . select_where_possible ( infcx) ;
226
+ if !errors. is_empty ( ) {
227
+ return errors;
228
+ }
229
+ }
230
+
231
+ self . predicates . to_errors ( CodeAmbiguity ) . into_iter ( ) . map ( to_fulfillment_error) . collect ( )
239
232
}
240
233
241
234
fn select_all_with_constness_or_error (
242
235
& mut self ,
243
236
infcx : & InferCtxt < ' _ , ' tcx > ,
244
237
constness : rustc_hir:: Constness ,
245
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
246
- self . select_with_constness_where_possible ( infcx, constness) ?;
247
-
248
- let errors: Vec < _ > = self
249
- . predicates
250
- . to_errors ( CodeAmbiguity )
251
- . into_iter ( )
252
- . map ( to_fulfillment_error)
253
- . collect ( ) ;
254
- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
238
+ ) -> Vec < FulfillmentError < ' tcx > > {
239
+ {
240
+ let errors = self . select_with_constness_where_possible ( infcx, constness) ;
241
+ if !errors. is_empty ( ) {
242
+ return errors;
243
+ }
244
+ }
245
+
246
+ self . predicates . to_errors ( CodeAmbiguity ) . into_iter ( ) . map ( to_fulfillment_error) . collect ( )
255
247
}
256
248
257
249
fn select_where_possible (
258
250
& mut self ,
259
251
infcx : & InferCtxt < ' _ , ' tcx > ,
260
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
252
+ ) -> Vec < FulfillmentError < ' tcx > > {
261
253
let mut selcx = SelectionContext :: new ( infcx) ;
262
254
self . select ( & mut selcx)
263
255
}
@@ -266,7 +258,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
266
258
& mut self ,
267
259
infcx : & InferCtxt < ' _ , ' tcx > ,
268
260
constness : hir:: Constness ,
269
- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
261
+ ) -> Vec < FulfillmentError < ' tcx > > {
270
262
let mut selcx = SelectionContext :: with_constness ( infcx, constness) ;
271
263
self . select ( & mut selcx)
272
264
}
0 commit comments