@@ -2,9 +2,11 @@ use super::implicit_clone::is_clone_like;
22use super :: unnecessary_iter_cloned:: { self , is_into_iter} ;
33use clippy_utils:: diagnostics:: span_lint_and_sugg;
44use 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} ;
66use 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+ } ;
810use clippy_utils:: { meets_msrv, msrvs} ;
911use rustc_errors:: Applicability ;
1012use rustc_hir:: { def_id:: DefId , BorrowKind , Expr , ExprKind , ItemKind , Node } ;
@@ -18,7 +20,9 @@ use rustc_middle::ty::EarlyBinder;
1820use rustc_middle:: ty:: { self , ParamTy , PredicateKind , ProjectionPredicate , TraitPredicate , Ty } ;
1921use rustc_semver:: RustcVersion ;
2022use 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+ } ;
2226use std:: cmp:: max;
2327
2428use super :: UNNECESSARY_TO_OWNED ;
@@ -146,7 +150,7 @@ fn check_addr_of_expr(
146150 if_chain! {
147151 if let Some ( deref_trait_id) = cx. tcx. get_diagnostic_item( sym:: Deref ) ;
148152 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) ;
150154 then {
151155 if n_receiver_refs > 0 {
152156 span_lint_and_sugg(
@@ -341,13 +345,13 @@ fn get_input_traits_and_projections<'tcx>(
341345 if trait_predicate. trait_ref . self_ty ( ) == input {
342346 trait_predicates. push ( trait_predicate) ;
343347 }
344- } ,
348+ }
345349 PredicateKind :: Projection ( projection_predicate) => {
346350 if projection_predicate. projection_ty . self_ty ( ) == input {
347351 projection_predicates. push ( projection_predicate) ;
348352 }
349- } ,
350- _ => { } ,
353+ }
354+ _ => { }
351355 }
352356 }
353357 ( trait_predicates, projection_predicates)
@@ -462,7 +466,12 @@ fn is_cloned_or_copied(cx: &LateContext<'_>, method_name: Symbol, method_def_id:
462466
463467/// Returns true if the named method can be used to convert the receiver to its "owned"
464468/// 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 {
466475 is_clone_like ( cx, method_name. as_str ( ) , method_def_id)
467476 || is_cow_into_owned ( cx, method_name, method_def_id)
468477 || 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>(
490499 && let GenericArgKind :: Type ( ty) = generic_arg. unpack ( )
491500 && let Some ( deref_trait_id) = cx. tcx . get_diagnostic_item ( sym:: Deref )
492501 && 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_ ) ||
494503 implements_trait ( cx, ty, as_ref_trait_id, & [ cx. tcx . types . str_ . into ( ) ] ) ) {
495504 true
496505 } else {
0 commit comments