@@ -16,7 +16,7 @@ use rustc_hir::{
16
16
} ;
17
17
use rustc_lint:: { LateContext , LateLintPass } ;
18
18
use rustc_middle:: hir:: nested_filter;
19
- use rustc_middle:: ty:: { self , AssocItems , AssocKind , Ty } ;
19
+ use rustc_middle:: ty:: { self , Ty } ;
20
20
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
21
21
use rustc_span:: source_map:: Span ;
22
22
use rustc_span:: symbol:: Symbol ;
@@ -308,7 +308,6 @@ struct PtrArg<'tcx> {
308
308
method_renames : & ' static [ ( & ' static str , & ' static str ) ] ,
309
309
ref_prefix : RefPrefix ,
310
310
deref_ty : DerefTy < ' tcx > ,
311
- deref_assoc_items : Option < ( DefId , & ' tcx AssocItems < ' tcx > ) > ,
312
311
}
313
312
impl PtrArg < ' _ > {
314
313
fn build_msg ( & self ) -> String {
@@ -411,7 +410,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
411
410
if params. get( i) . map_or( true , |p| !is_lint_allowed( cx, PTR_ARG , p. hir_id) ) ;
412
411
413
412
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( ) ) {
415
414
Some ( sym:: Vec ) => (
416
415
[ ( "clone" , ".to_owned()" ) ] . as_slice( ) ,
417
416
DerefTy :: Slice (
@@ -424,17 +423,14 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
424
423
} ) ,
425
424
substs. type_at( 0 ) ,
426
425
) ,
427
- cx. tcx. lang_items( ) . slice_impl( )
428
426
) ,
429
427
Some ( sym:: String ) => (
430
428
[ ( "clone" , ".to_owned()" ) , ( "as_str" , "" ) ] . as_slice( ) ,
431
429
DerefTy :: Str ,
432
- cx. tcx. lang_items( ) . str_impl( )
433
430
) ,
434
431
Some ( sym:: PathBuf ) => (
435
432
[ ( "clone" , ".to_path_buf()" ) , ( "as_path" , "" ) ] . as_slice( ) ,
436
433
DerefTy :: Path ,
437
- None ,
438
434
) ,
439
435
Some ( sym:: Cow ) if mutability == Mutability :: Not => {
440
436
let ty_name = name. args
@@ -470,7 +466,6 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
470
466
mutability,
471
467
} ,
472
468
deref_ty,
473
- deref_assoc_items: deref_impl_id. map( |id| ( id, cx. tcx. associated_items( id) ) ) ,
474
469
} ) ;
475
470
}
476
471
}
@@ -607,14 +602,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
607
602
// If the types match check for methods which exist on both types. e.g. `Vec::len` and
608
603
// `slice::len`
609
604
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 =>
618
606
{
619
607
set_skip_flag ( ) ;
620
608
} ,
0 commit comments