@@ -46,7 +46,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
46
46
return None ;
47
47
}
48
48
49
- let result = f. find_auto_trait_generics ( ty, param_env, trait_def_id, |infcx , info| {
49
+ let result = f. find_auto_trait_generics ( ty, param_env, trait_def_id, |info| {
50
50
let region_data = info. region_data ;
51
51
52
52
let names_map = tcx
@@ -61,7 +61,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
61
61
. collect ( ) ;
62
62
let lifetime_predicates = Self :: handle_lifetimes ( & region_data, & names_map) ;
63
63
let new_generics = self . param_env_to_generics (
64
- infcx. tcx ,
65
64
item_def_id,
66
65
info. full_user_env ,
67
66
lifetime_predicates,
@@ -313,12 +312,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
313
312
lifetime_predicates
314
313
}
315
314
316
- fn extract_for_generics (
317
- & self ,
318
- tcx : TyCtxt < ' tcx > ,
319
- pred : ty:: Predicate < ' tcx > ,
320
- ) -> FxHashSet < GenericParamDef > {
315
+ fn extract_for_generics ( & self , pred : ty:: Predicate < ' tcx > ) -> FxHashSet < GenericParamDef > {
321
316
let bound_predicate = pred. kind ( ) ;
317
+ let tcx = self . cx . tcx ;
322
318
let regions = match bound_predicate. skip_binder ( ) {
323
319
ty:: PredicateKind :: Trait ( poly_trait_pred, _) => {
324
320
tcx. collect_referenced_late_bound_regions ( & bound_predicate. rebind ( poly_trait_pred) )
@@ -443,7 +439,6 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
443
439
// * We explicitly add a '?Sized' bound if we didn't find any 'Sized' predicates for a type
444
440
fn param_env_to_generics (
445
441
& mut self ,
446
- tcx : TyCtxt < ' tcx > ,
447
442
item_def_id : DefId ,
448
443
param_env : ty:: ParamEnv < ' tcx > ,
449
444
mut existing_predicates : Vec < WherePredicate > ,
@@ -455,14 +450,15 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
455
450
item_def_id, param_env, existing_predicates
456
451
) ;
457
452
453
+ let tcx = self . cx . tcx ;
454
+
458
455
// The `Sized` trait must be handled specially, since we only display it when
459
456
// it is *not* required (i.e., '?Sized')
460
- let sized_trait = self . cx . tcx . require_lang_item ( LangItem :: Sized , None ) ;
457
+ let sized_trait = tcx. require_lang_item ( LangItem :: Sized , None ) ;
461
458
462
459
let mut replacer = RegionReplacer { vid_to_region : & vid_to_region, tcx } ;
463
460
464
- let orig_bounds: FxHashSet < _ > =
465
- self . cx . tcx . param_env ( item_def_id) . caller_bounds ( ) . iter ( ) . collect ( ) ;
461
+ let orig_bounds: FxHashSet < _ > = tcx. param_env ( item_def_id) . caller_bounds ( ) . iter ( ) . collect ( ) ;
466
462
let clean_where_predicates = param_env
467
463
. caller_bounds ( )
468
464
. iter ( )
@@ -512,7 +508,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
512
508
continue ;
513
509
}
514
510
515
- let mut for_generics = self . extract_for_generics ( tcx , orig_p) ;
511
+ let mut for_generics = self . extract_for_generics ( orig_p) ;
516
512
517
513
assert ! ( bounds. len( ) == 1 ) ;
518
514
let mut b = bounds. pop ( ) . expect ( "bounds were empty" ) ;
@@ -541,7 +537,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
541
537
// that we don't end up with duplicate bounds (e.g., for<'b, 'b>)
542
538
for_generics. extend ( p. generic_params . clone ( ) ) ;
543
539
p. generic_params = for_generics. into_iter ( ) . collect ( ) ;
544
- self . is_fn_ty ( tcx , & p. trait_ )
540
+ self . is_fn_ty ( & p. trait_ )
545
541
}
546
542
_ => false ,
547
543
} ;
@@ -576,7 +572,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
576
572
} => {
577
573
let mut new_trait_path = trait_path. clone ( ) ;
578
574
579
- if self . is_fn_ty ( tcx , trait_) && left_name == sym:: Output {
575
+ if self . is_fn_ty ( trait_) && left_name == sym:: Output {
580
576
ty_to_fn
581
577
. entry ( * ty. clone ( ) )
582
578
. and_modify ( |e| * e = ( e. 0 . clone ( ) , Some ( rhs. clone ( ) ) ) )
@@ -734,7 +730,8 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
734
730
vec. sort_by_cached_key ( |x| format ! ( "{:?}" , x) )
735
731
}
736
732
737
- fn is_fn_ty ( & self , tcx : TyCtxt < ' _ > , ty : & Type ) -> bool {
733
+ fn is_fn_ty ( & self , ty : & Type ) -> bool {
734
+ let tcx = self . cx . tcx ;
738
735
match ty {
739
736
& Type :: ResolvedPath { did, .. } => {
740
737
did == tcx. require_lang_item ( LangItem :: Fn , None )
0 commit comments