@@ -2,9 +2,11 @@ use super::implicit_clone::is_clone_like;
2
2
use super :: unnecessary_iter_cloned:: { self , is_into_iter} ;
3
3
use clippy_utils:: diagnostics:: span_lint_and_sugg;
4
4
use clippy_utils:: source:: snippet_opt;
5
- use clippy_utils:: ty:: { get_associated_type , get_iterator_item_ty, implements_trait, is_copy, peel_mid_ty_refs} ;
5
+ use clippy_utils:: ty:: { get_iterator_item_ty, implements_trait, is_copy, peel_mid_ty_refs} ;
6
6
use clippy_utils:: visitors:: find_all_ret_expressions;
7
- use clippy_utils:: { fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, return_ty} ;
7
+ use clippy_utils:: {
8
+ fn_def_id, get_parent_expr, is_diag_item_method, is_diag_trait_item, return_ty,
9
+ } ;
8
10
use clippy_utils:: { meets_msrv, msrvs} ;
9
11
use rustc_errors:: Applicability ;
10
12
use rustc_hir:: { def_id:: DefId , BorrowKind , Expr , ExprKind , ItemKind , Node } ;
@@ -18,7 +20,9 @@ use rustc_middle::ty::EarlyBinder;
18
20
use rustc_middle:: ty:: { self , ParamTy , PredicateKind , ProjectionPredicate , TraitPredicate , Ty } ;
19
21
use rustc_semver:: RustcVersion ;
20
22
use rustc_span:: { sym, Symbol } ;
21
- use rustc_trait_selection:: traits:: { query:: evaluate_obligation:: InferCtxtExt as _, Obligation , ObligationCause } ;
23
+ use rustc_trait_selection:: traits:: {
24
+ query:: evaluate_obligation:: InferCtxtExt as _, Obligation , ObligationCause ,
25
+ } ;
22
26
use std:: cmp:: max;
23
27
24
28
use super :: UNNECESSARY_TO_OWNED ;
@@ -146,7 +150,7 @@ fn check_addr_of_expr(
146
150
if_chain! {
147
151
if let Some ( deref_trait_id) = cx. tcx. get_diagnostic_item( sym:: Deref ) ;
148
152
if implements_trait( cx, receiver_ty, deref_trait_id, & [ ] ) ;
149
- if get_associated_type( cx , receiver_ty, deref_trait_id, "Target" ) == Some ( target_ty) ;
153
+ if cx . get_associated_type( receiver_ty, deref_trait_id, "Target" ) == Some ( target_ty) ;
150
154
then {
151
155
if n_receiver_refs > 0 {
152
156
span_lint_and_sugg(
@@ -341,13 +345,13 @@ fn get_input_traits_and_projections<'tcx>(
341
345
if trait_predicate. trait_ref . self_ty ( ) == input {
342
346
trait_predicates. push ( trait_predicate) ;
343
347
}
344
- } ,
348
+ }
345
349
PredicateKind :: Projection ( projection_predicate) => {
346
350
if projection_predicate. projection_ty . self_ty ( ) == input {
347
351
projection_predicates. push ( projection_predicate) ;
348
352
}
349
- } ,
350
- _ => { } ,
353
+ }
354
+ _ => { }
351
355
}
352
356
}
353
357
( trait_predicates, projection_predicates)
@@ -462,7 +466,12 @@ fn is_cloned_or_copied(cx: &LateContext<'_>, method_name: Symbol, method_def_id:
462
466
463
467
/// Returns true if the named method can be used to convert the receiver to its "owned"
464
468
/// representation.
465
- fn is_to_owned_like < ' a > ( cx : & LateContext < ' a > , call_expr : & Expr < ' a > , method_name : Symbol , method_def_id : DefId ) -> bool {
469
+ fn is_to_owned_like < ' a > (
470
+ cx : & LateContext < ' a > ,
471
+ call_expr : & Expr < ' a > ,
472
+ method_name : Symbol ,
473
+ method_def_id : DefId ,
474
+ ) -> bool {
466
475
is_clone_like ( cx, method_name. as_str ( ) , method_def_id)
467
476
|| is_cow_into_owned ( cx, method_name, method_def_id)
468
477
|| is_to_string_on_string_like ( cx, call_expr, method_name, method_def_id)
@@ -490,7 +499,7 @@ fn is_to_string_on_string_like<'a>(
490
499
&& let GenericArgKind :: Type ( ty) = generic_arg. unpack ( )
491
500
&& let Some ( deref_trait_id) = cx. tcx . get_diagnostic_item ( sym:: Deref )
492
501
&& let Some ( as_ref_trait_id) = cx. tcx . get_diagnostic_item ( sym:: AsRef )
493
- && ( get_associated_type ( cx , ty, deref_trait_id, "Target" ) == Some ( cx. tcx . types . str_ ) ||
502
+ && ( cx . get_associated_type ( ty, deref_trait_id, "Target" ) == Some ( cx. tcx . types . str_ ) ||
494
503
implements_trait ( cx, ty, as_ref_trait_id, & [ cx. tcx . types . str_ . into ( ) ] ) ) {
495
504
true
496
505
} else {
0 commit comments