@@ -247,7 +247,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
247
247
248
248
let mut candidates = SelectionCandidateSet { vec : Vec :: new ( ) , ambiguous : false } ;
249
249
250
- self . assemble_candidates_for_trait_alias ( obligation, & mut candidates) ? ;
250
+ self . assemble_candidates_for_trait_alias ( obligation, & mut candidates) ;
251
251
252
252
// Other bounds. Consider both in-scope bounds from fn decl
253
253
// and applicable impls. There is a certain set of precedence rules here.
@@ -259,19 +259,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
259
259
260
260
// User-defined copy impls are permitted, but only for
261
261
// structs and enums.
262
- self . assemble_candidates_from_impls ( obligation, & mut candidates) ? ;
262
+ self . assemble_candidates_from_impls ( obligation, & mut candidates) ;
263
263
264
264
// For other types, we'll use the builtin rules.
265
265
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) ;
267
267
} else if lang_items. discriminant_kind_trait ( ) == Some ( def_id) {
268
268
// `DiscriminantKind` is automatically implemented for every type.
269
269
candidates. vec . push ( DiscriminantKindCandidate ) ;
270
270
} else if lang_items. sized_trait ( ) == Some ( def_id) {
271
271
// Sized is never implementable by end-users, it is
272
272
// always automatically computed.
273
273
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) ;
275
275
} else if lang_items. unsize_trait ( ) == Some ( def_id) {
276
276
self . assemble_candidates_for_unsizing ( obligation, & mut candidates) ;
277
277
} else {
@@ -280,13 +280,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
280
280
// for `Copy` also has builtin support for `Clone`, and tuples/arrays of `Clone`
281
281
// types have builtin support for `Clone`.
282
282
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) ;
284
284
}
285
285
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) ;
290
290
self . assemble_candidates_from_object_ty ( obligation, & mut candidates) ;
291
291
}
292
292
@@ -295,7 +295,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
295
295
// Auto implementations have lower priority, so we only
296
296
// consider triggering a default if there is no other impl that can apply.
297
297
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) ;
299
299
}
300
300
debug ! ( "candidate list size: {}" , candidates. vec. len( ) ) ;
301
301
Ok ( candidates)
@@ -367,9 +367,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
367
367
& mut self ,
368
368
obligation : & TraitObligation < ' tcx > ,
369
369
candidates : & mut SelectionCandidateSet < ' tcx > ,
370
- ) -> Result < ( ) , SelectionError < ' tcx > > {
370
+ ) {
371
371
if self . tcx ( ) . lang_items ( ) . gen_trait ( ) != Some ( obligation. predicate . def_id ( ) ) {
372
- return Ok ( ( ) ) ;
372
+ return ;
373
373
}
374
374
375
375
// Okay to skip binder because the substs on generator types never
@@ -388,8 +388,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
388
388
}
389
389
_ => { }
390
390
}
391
-
392
- Ok ( ( ) )
393
391
}
394
392
395
393
/// 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> {
402
400
& mut self ,
403
401
obligation : & TraitObligation < ' tcx > ,
404
402
candidates : & mut SelectionCandidateSet < ' tcx > ,
405
- ) -> Result < ( ) , SelectionError < ' tcx > > {
403
+ ) {
406
404
let kind = match self . tcx ( ) . fn_trait_kind_from_lang_item ( obligation. predicate . def_id ( ) ) {
407
405
Some ( k) => k,
408
406
None => {
409
- return Ok ( ( ) ) ;
407
+ return ;
410
408
}
411
409
} ;
412
410
@@ -435,19 +433,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
435
433
}
436
434
_ => { }
437
435
}
438
-
439
- Ok ( ( ) )
440
436
}
441
437
442
438
/// Implements one of the `Fn()` family for a fn pointer.
443
439
fn assemble_fn_pointer_candidates (
444
440
& mut self ,
445
441
obligation : & TraitObligation < ' tcx > ,
446
442
candidates : & mut SelectionCandidateSet < ' tcx > ,
447
- ) -> Result < ( ) , SelectionError < ' tcx > > {
443
+ ) {
448
444
// We provide impl of all fn traits for fn pointers.
449
445
if self . tcx ( ) . fn_trait_kind_from_lang_item ( obligation. predicate . def_id ( ) ) . is_none ( ) {
450
- return Ok ( ( ) ) ;
446
+ return ;
451
447
}
452
448
453
449
// Okay to skip binder because what we are inspecting doesn't involve bound regions.
@@ -485,16 +481,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
485
481
}
486
482
_ => { }
487
483
}
488
-
489
- Ok ( ( ) )
490
484
}
491
485
492
486
/// Searches for impls that might apply to `obligation`.
493
487
fn assemble_candidates_from_impls (
494
488
& mut self ,
495
489
obligation : & TraitObligation < ' tcx > ,
496
490
candidates : & mut SelectionCandidateSet < ' tcx > ,
497
- ) -> Result < ( ) , SelectionError < ' tcx > > {
491
+ ) {
498
492
debug ! ( ?obligation, "assemble_candidates_from_impls" ) ;
499
493
500
494
// Essentially any user-written impl will match with an error type,
@@ -504,7 +498,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
504
498
// Since compilation is already guaranteed to fail, this is just
505
499
// to try to show the 'nicest' possible errors to the user.
506
500
if obligation. references_error ( ) {
507
- return Ok ( ( ) ) ;
501
+ return ;
508
502
}
509
503
510
504
self . tcx ( ) . for_each_relevant_impl (
@@ -518,15 +512,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
518
512
} ) ;
519
513
} ,
520
514
) ;
521
-
522
- Ok ( ( ) )
523
515
}
524
516
525
517
fn assemble_candidates_from_auto_impls (
526
518
& mut self ,
527
519
obligation : & TraitObligation < ' tcx > ,
528
520
candidates : & mut SelectionCandidateSet < ' tcx > ,
529
- ) -> Result < ( ) , SelectionError < ' tcx > > {
521
+ ) {
530
522
// Okay to skip binder here because the tests we do below do not involve bound regions.
531
523
let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
532
524
debug ! ( ?self_ty, "assemble_candidates_from_auto_impls" ) ;
@@ -585,8 +577,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
585
577
_ => candidates. vec . push ( AutoImplCandidate ( def_id) ) ,
586
578
}
587
579
}
588
-
589
- Ok ( ( ) )
590
580
}
591
581
592
582
/// Searches for impls that might apply to `obligation`.
@@ -753,7 +743,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
753
743
& mut self ,
754
744
obligation : & TraitObligation < ' tcx > ,
755
745
candidates : & mut SelectionCandidateSet < ' tcx > ,
756
- ) -> Result < ( ) , SelectionError < ' tcx > > {
746
+ ) {
757
747
// Okay to skip binder here because the tests we do below do not involve bound regions.
758
748
let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
759
749
debug ! ( ?self_ty, "assemble_candidates_for_trait_alias" ) ;
@@ -763,8 +753,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
763
753
if self . tcx ( ) . is_trait_alias ( def_id) {
764
754
candidates. vec . push ( TraitAliasCandidate ( def_id) ) ;
765
755
}
766
-
767
- Ok ( ( ) )
768
756
}
769
757
770
758
/// Assembles the trait which are built-in to the language itself:
@@ -773,7 +761,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
773
761
& mut self ,
774
762
conditions : BuiltinImplConditions < ' tcx > ,
775
763
candidates : & mut SelectionCandidateSet < ' tcx > ,
776
- ) -> Result < ( ) , SelectionError < ' tcx > > {
764
+ ) {
777
765
match conditions {
778
766
BuiltinImplConditions :: Where ( nested) => {
779
767
debug ! ( ?nested, "builtin_bound" ) ;
@@ -787,7 +775,5 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
787
775
candidates. ambiguous = true ;
788
776
}
789
777
}
790
-
791
- Ok ( ( ) )
792
778
}
793
779
}
0 commit comments