@@ -247,7 +247,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
247247
248248 let mut candidates = SelectionCandidateSet { vec : Vec :: new ( ) , ambiguous : false } ;
249249
250- self . assemble_candidates_for_trait_alias ( obligation, & mut candidates) ? ;
250+ self . assemble_candidates_for_trait_alias ( obligation, & mut candidates) ;
251251
252252 // Other bounds. Consider both in-scope bounds from fn decl
253253 // and applicable impls. There is a certain set of precedence rules here.
@@ -259,19 +259,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
259259
260260 // User-defined copy impls are permitted, but only for
261261 // structs and enums.
262- self . assemble_candidates_from_impls ( obligation, & mut candidates) ? ;
262+ self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
263263
264264 // For other types, we'll use the builtin rules.
265265 let copy_conditions = self . copy_clone_conditions ( obligation) ;
266- self . assemble_builtin_bound_candidates ( copy_conditions, & mut candidates) ? ;
266+ self . assemble_builtin_bound_candidates ( copy_conditions, & mut candidates) ;
267267 } else if lang_items. discriminant_kind_trait ( ) == Some ( def_id) {
268268 // `DiscriminantKind` is automatically implemented for every type.
269269 candidates. vec . push ( DiscriminantKindCandidate ) ;
270270 } else if lang_items. sized_trait ( ) == Some ( def_id) {
271271 // Sized is never implementable by end-users, it is
272272 // always automatically computed.
273273 let sized_conditions = self . sized_conditions ( obligation) ;
274- self . assemble_builtin_bound_candidates ( sized_conditions, & mut candidates) ? ;
274+ self . assemble_builtin_bound_candidates ( sized_conditions, & mut candidates) ;
275275 } else if lang_items. unsize_trait ( ) == Some ( def_id) {
276276 self . assemble_candidates_for_unsizing ( obligation, & mut candidates) ;
277277 } else {
@@ -280,13 +280,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
280280 // for `Copy` also has builtin support for `Clone`, and tuples/arrays of `Clone`
281281 // types have builtin support for `Clone`.
282282 let clone_conditions = self . copy_clone_conditions ( obligation) ;
283- self . assemble_builtin_bound_candidates ( clone_conditions, & mut candidates) ? ;
283+ self . assemble_builtin_bound_candidates ( clone_conditions, & mut candidates) ;
284284 }
285285
286- self . assemble_generator_candidates ( obligation, & mut candidates) ? ;
287- self . assemble_closure_candidates ( obligation, & mut candidates) ? ;
288- self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ? ;
289- self . assemble_candidates_from_impls ( obligation, & mut candidates) ? ;
286+ self . assemble_generator_candidates ( obligation, & mut candidates) ;
287+ self . assemble_closure_candidates ( obligation, & mut candidates) ;
288+ self . assemble_fn_pointer_candidates ( obligation, & mut candidates) ;
289+ self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
290290 self . assemble_candidates_from_object_ty ( obligation, & mut candidates) ;
291291 }
292292
@@ -295,7 +295,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
295295 // Auto implementations have lower priority, so we only
296296 // consider triggering a default if there is no other impl that can apply.
297297 if candidates. vec . is_empty ( ) {
298- self . assemble_candidates_from_auto_impls ( obligation, & mut candidates) ? ;
298+ self . assemble_candidates_from_auto_impls ( obligation, & mut candidates) ;
299299 }
300300 debug ! ( "candidate list size: {}" , candidates. vec. len( ) ) ;
301301 Ok ( candidates)
@@ -367,9 +367,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
367367 & mut self ,
368368 obligation : & TraitObligation < ' tcx > ,
369369 candidates : & mut SelectionCandidateSet < ' tcx > ,
370- ) -> Result < ( ) , SelectionError < ' tcx > > {
370+ ) {
371371 if self . tcx ( ) . lang_items ( ) . gen_trait ( ) != Some ( obligation. predicate . def_id ( ) ) {
372- return Ok ( ( ) ) ;
372+ return ;
373373 }
374374
375375 // Okay to skip binder because the substs on generator types never
@@ -388,8 +388,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
388388 }
389389 _ => { }
390390 }
391-
392- Ok ( ( ) )
393391 }
394392
395393 /// Checks for the artificial impl that the compiler will create for an obligation like `X :
@@ -402,11 +400,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
402400 & mut self ,
403401 obligation : & TraitObligation < ' tcx > ,
404402 candidates : & mut SelectionCandidateSet < ' tcx > ,
405- ) -> Result < ( ) , SelectionError < ' tcx > > {
403+ ) {
406404 let kind = match self . tcx ( ) . fn_trait_kind_from_lang_item ( obligation. predicate . def_id ( ) ) {
407405 Some ( k) => k,
408406 None => {
409- return Ok ( ( ) ) ;
407+ return ;
410408 }
411409 } ;
412410
@@ -435,19 +433,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
435433 }
436434 _ => { }
437435 }
438-
439- Ok ( ( ) )
440436 }
441437
442438 /// Implements one of the `Fn()` family for a fn pointer.
443439 fn assemble_fn_pointer_candidates (
444440 & mut self ,
445441 obligation : & TraitObligation < ' tcx > ,
446442 candidates : & mut SelectionCandidateSet < ' tcx > ,
447- ) -> Result < ( ) , SelectionError < ' tcx > > {
443+ ) {
448444 // We provide impl of all fn traits for fn pointers.
449445 if self . tcx ( ) . fn_trait_kind_from_lang_item ( obligation. predicate . def_id ( ) ) . is_none ( ) {
450- return Ok ( ( ) ) ;
446+ return ;
451447 }
452448
453449 // Okay to skip binder because what we are inspecting doesn't involve bound regions.
@@ -485,16 +481,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
485481 }
486482 _ => { }
487483 }
488-
489- Ok ( ( ) )
490484 }
491485
492486 /// Searches for impls that might apply to `obligation`.
493487 fn assemble_candidates_from_impls (
494488 & mut self ,
495489 obligation : & TraitObligation < ' tcx > ,
496490 candidates : & mut SelectionCandidateSet < ' tcx > ,
497- ) -> Result < ( ) , SelectionError < ' tcx > > {
491+ ) {
498492 debug ! ( ?obligation, "assemble_candidates_from_impls" ) ;
499493
500494 // Essentially any user-written impl will match with an error type,
@@ -504,7 +498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
504498 // Since compilation is already guaranteed to fail, this is just
505499 // to try to show the 'nicest' possible errors to the user.
506500 if obligation. references_error ( ) {
507- return Ok ( ( ) ) ;
501+ return ;
508502 }
509503
510504 self . tcx ( ) . for_each_relevant_impl (
@@ -518,15 +512,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
518512 } ) ;
519513 } ,
520514 ) ;
521-
522- Ok ( ( ) )
523515 }
524516
525517 fn assemble_candidates_from_auto_impls (
526518 & mut self ,
527519 obligation : & TraitObligation < ' tcx > ,
528520 candidates : & mut SelectionCandidateSet < ' tcx > ,
529- ) -> Result < ( ) , SelectionError < ' tcx > > {
521+ ) {
530522 // Okay to skip binder here because the tests we do below do not involve bound regions.
531523 let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
532524 debug ! ( ?self_ty, "assemble_candidates_from_auto_impls" ) ;
@@ -585,8 +577,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
585577 _ => candidates. vec . push ( AutoImplCandidate ( def_id) ) ,
586578 }
587579 }
588-
589- Ok ( ( ) )
590580 }
591581
592582 /// Searches for impls that might apply to `obligation`.
@@ -753,7 +743,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
753743 & mut self ,
754744 obligation : & TraitObligation < ' tcx > ,
755745 candidates : & mut SelectionCandidateSet < ' tcx > ,
756- ) -> Result < ( ) , SelectionError < ' tcx > > {
746+ ) {
757747 // Okay to skip binder here because the tests we do below do not involve bound regions.
758748 let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
759749 debug ! ( ?self_ty, "assemble_candidates_for_trait_alias" ) ;
@@ -763,8 +753,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
763753 if self . tcx ( ) . is_trait_alias ( def_id) {
764754 candidates. vec . push ( TraitAliasCandidate ( def_id) ) ;
765755 }
766-
767- Ok ( ( ) )
768756 }
769757
770758 /// Assembles the trait which are built-in to the language itself:
@@ -773,7 +761,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
773761 & mut self ,
774762 conditions : BuiltinImplConditions < ' tcx > ,
775763 candidates : & mut SelectionCandidateSet < ' tcx > ,
776- ) -> Result < ( ) , SelectionError < ' tcx > > {
764+ ) {
777765 match conditions {
778766 BuiltinImplConditions :: Where ( nested) => {
779767 debug ! ( ?nested, "builtin_bound" ) ;
@@ -787,7 +775,5 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
787775 candidates. ambiguous = true ;
788776 }
789777 }
790-
791- Ok ( ( ) )
792778 }
793779}
0 commit comments