@@ -129,7 +129,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
129129 fn select (
130130 & mut self ,
131131 selcx : & mut SelectionContext < ' a , ' tcx > ,
132- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
132+ ) -> Vec < FulfillmentError < ' tcx > > {
133133 let span = debug_span ! ( "select" , obligation_forest_size = ?self . predicates. len( ) ) ;
134134 let _enter = span. enter ( ) ;
135135
@@ -163,7 +163,7 @@ impl<'a, 'tcx> FulfillmentContext<'tcx> {
163163 errors. len( )
164164 ) ;
165165
166- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors ) }
166+ errors
167167 }
168168}
169169
@@ -226,38 +226,46 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
226226 fn select_all_or_error (
227227 & mut self ,
228228 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+ }
231236
232- let errors : Vec < _ > = self
237+ self
233238 . predicates
234239 . to_errors ( CodeAmbiguity )
235240 . into_iter ( )
236241 . map ( to_fulfillment_error)
237- . collect ( ) ;
238- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
242+ . collect ( )
239243 }
240244
241245 fn select_all_with_constness_or_error (
242246 & mut self ,
243247 infcx : & InferCtxt < ' _ , ' tcx > ,
244248 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+ }
247256
248- let errors : Vec < _ > = self
257+ self
249258 . predicates
250259 . to_errors ( CodeAmbiguity )
251260 . into_iter ( )
252261 . map ( to_fulfillment_error)
253- . collect ( ) ;
254- if errors. is_empty ( ) { Ok ( ( ) ) } else { Err ( errors) }
262+ . collect ( )
255263 }
256264
257265 fn select_where_possible (
258266 & mut self ,
259267 infcx : & InferCtxt < ' _ , ' tcx > ,
260- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
268+ ) -> Vec < FulfillmentError < ' tcx > > {
261269 let mut selcx = SelectionContext :: new ( infcx) ;
262270 self . select ( & mut selcx)
263271 }
@@ -266,7 +274,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentContext<'tcx> {
266274 & mut self ,
267275 infcx : & InferCtxt < ' _ , ' tcx > ,
268276 constness : hir:: Constness ,
269- ) -> Result < ( ) , Vec < FulfillmentError < ' tcx > > > {
277+ ) -> Vec < FulfillmentError < ' tcx > > {
270278 let mut selcx = SelectionContext :: with_constness ( infcx, constness) ;
271279 self . select ( & mut selcx)
272280 }
0 commit comments