@@ -16,7 +16,7 @@ use rustc_hir::{
1616} ;
1717use rustc_lint:: { LateContext , LateLintPass } ;
1818use rustc_middle:: hir:: nested_filter;
19- use rustc_middle:: ty:: { self , AssocItems , AssocKind , Ty } ;
19+ use rustc_middle:: ty:: { self , Ty } ;
2020use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
2121use rustc_span:: source_map:: Span ;
2222use rustc_span:: symbol:: Symbol ;
@@ -308,7 +308,6 @@ struct PtrArg<'tcx> {
308308 method_renames : & ' static [ ( & ' static str , & ' static str ) ] ,
309309 ref_prefix : RefPrefix ,
310310 deref_ty : DerefTy < ' tcx > ,
311- deref_assoc_items : Option < ( DefId , & ' tcx AssocItems < ' tcx > ) > ,
312311}
313312impl PtrArg < ' _ > {
314313 fn build_msg ( & self ) -> String {
@@ -411,7 +410,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
411410 if params. get( i) . map_or( true , |p| !is_lint_allowed( cx, PTR_ARG , p. hir_id) ) ;
412411
413412 then {
414- let ( method_renames, deref_ty, deref_impl_id ) = match cx. tcx. get_diagnostic_name( adt. did( ) ) {
413+ let ( method_renames, deref_ty) = match cx. tcx. get_diagnostic_name( adt. did( ) ) {
415414 Some ( sym:: Vec ) => (
416415 [ ( "clone" , ".to_owned()" ) ] . as_slice( ) ,
417416 DerefTy :: Slice (
@@ -424,17 +423,14 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
424423 } ) ,
425424 substs. type_at( 0 ) ,
426425 ) ,
427- cx. tcx. lang_items( ) . slice_impl( )
428426 ) ,
429427 Some ( sym:: String ) => (
430428 [ ( "clone" , ".to_owned()" ) , ( "as_str" , "" ) ] . as_slice( ) ,
431429 DerefTy :: Str ,
432- cx. tcx. lang_items( ) . str_impl( )
433430 ) ,
434431 Some ( sym:: PathBuf ) => (
435432 [ ( "clone" , ".to_path_buf()" ) , ( "as_path" , "" ) ] . as_slice( ) ,
436433 DerefTy :: Path ,
437- None ,
438434 ) ,
439435 Some ( sym:: Cow ) if mutability == Mutability :: Not => {
440436 let ty_name = name. args
@@ -470,7 +466,6 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
470466 mutability,
471467 } ,
472468 deref_ty,
473- deref_assoc_items: deref_impl_id. map( |id| ( id, cx. tcx. associated_items( id) ) ) ,
474469 } ) ;
475470 }
476471 }
@@ -607,14 +602,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
607602 // If the types match check for methods which exist on both types. e.g. `Vec::len` and
608603 // `slice::len`
609604 ty:: Adt ( def, _)
610- if def. did ( ) == args. ty_did
611- && ( i != 0
612- || self . cx . tcx . trait_of_item ( id) . is_some ( )
613- || !args. deref_assoc_items . map_or ( false , |( id, items) | {
614- items
615- . find_by_name_and_kind ( self . cx . tcx , name. ident , AssocKind :: Fn , id)
616- . is_some ( )
617- } ) ) =>
605+ if def. did ( ) == args. ty_did =>
618606 {
619607 set_skip_flag ( ) ;
620608 } ,
0 commit comments