1
1
use clippy_utils:: diagnostics:: { span_lint, span_lint_and_then} ;
2
2
use clippy_utils:: trait_ref_of_method;
3
3
use itertools:: Itertools ;
4
- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
4
+ use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
5
5
use rustc_errors:: Applicability ;
6
6
use rustc_hir:: FnRetTy :: Return ;
7
7
use rustc_hir:: intravisit:: nested_filter:: { self as hir_nested_filter, NestedFilter } ;
8
8
use rustc_hir:: intravisit:: {
9
- Visitor , walk_fn_decl, walk_generic_args, walk_generics, walk_impl_item_ref, walk_item , walk_param_bound ,
10
- walk_poly_trait_ref , walk_trait_ref, walk_ty, walk_where_predicate,
9
+ Visitor , walk_fn_decl, walk_generic_args, walk_generics, walk_impl_item_ref, walk_param_bound , walk_poly_trait_ref ,
10
+ walk_trait_ref, walk_ty, walk_where_predicate,
11
11
} ;
12
12
use rustc_hir:: {
13
13
BareFnTy , BodyId , FnDecl , FnSig , GenericArg , GenericArgs , GenericBound , GenericParam , GenericParamKind , Generics ,
@@ -163,7 +163,7 @@ fn check_fn_inner<'tcx>(
163
163
if visitor. lts . iter ( ) . any ( |lt| matches ! ( lt. res, LifetimeName :: Param ( _) ) ) {
164
164
return ;
165
165
}
166
- if let GenericBound :: Trait ( ref trait_ref, _ ) = * bound {
166
+ if let GenericBound :: Trait ( ref trait_ref) = * bound {
167
167
let params = & trait_ref
168
168
. trait_ref
169
169
. path
@@ -311,7 +311,7 @@ fn could_use_elision<'tcx>(
311
311
Some ( ( elidable_lts, usages) )
312
312
}
313
313
314
- fn allowed_lts_from ( named_generics : & [ GenericParam < ' _ > ] ) -> FxHashSet < LocalDefId > {
314
+ fn allowed_lts_from ( named_generics : & [ GenericParam < ' _ > ] ) -> FxIndexSet < LocalDefId > {
315
315
named_generics
316
316
. iter ( )
317
317
. filter_map ( |par| {
@@ -420,11 +420,9 @@ impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> {
420
420
421
421
fn visit_ty ( & mut self , ty : & ' tcx Ty < ' _ > ) {
422
422
match ty. kind {
423
- TyKind :: OpaqueDef ( item, bounds, _) => {
424
- let map = self . cx . tcx . hir ( ) ;
425
- let item = map. item ( item) ;
423
+ TyKind :: OpaqueDef ( opaque, bounds) => {
426
424
let len = self . lts . len ( ) ;
427
- walk_item ( self , item ) ;
425
+ self . visit_opaque_ty ( opaque ) ;
428
426
self . lts . truncate ( len) ;
429
427
self . lts . extend ( bounds. iter ( ) . filter_map ( |bound| match bound {
430
428
GenericArg :: Lifetime ( & l) => Some ( l) ,
@@ -440,7 +438,7 @@ impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> {
440
438
if !lt. is_elided ( ) {
441
439
self . unelided_trait_object_lifetime = true ;
442
440
}
443
- for ( bound, _ ) in bounds {
441
+ for bound in bounds {
444
442
self . visit_poly_trait_ref ( bound) ;
445
443
}
446
444
} ,
@@ -499,7 +497,7 @@ struct Usage {
499
497
500
498
struct LifetimeChecker < ' cx , ' tcx , F > {
501
499
cx : & ' cx LateContext < ' tcx > ,
502
- map : FxHashMap < LocalDefId , Vec < Usage > > ,
500
+ map : FxIndexMap < LocalDefId , Vec < Usage > > ,
503
501
where_predicate_depth : usize ,
504
502
generic_args_depth : usize ,
505
503
phantom : std:: marker:: PhantomData < F > ,
@@ -621,7 +619,7 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
621
619
fn report_elidable_impl_lifetimes < ' tcx > (
622
620
cx : & LateContext < ' tcx > ,
623
621
impl_ : & ' tcx Impl < ' _ > ,
624
- map : & FxHashMap < LocalDefId , Vec < Usage > > ,
622
+ map : & FxIndexMap < LocalDefId , Vec < Usage > > ,
625
623
) {
626
624
let single_usages = map
627
625
. iter ( )
0 commit comments