File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1- use clippy_utils:: diagnostics:: span_lint_and_help ;
1+ use clippy_utils:: diagnostics:: span_lint_hir_and_then ;
22use clippy_utils:: { is_from_proc_macro, is_in_test_function} ;
33use rustc_data_structures:: fx:: FxHashMap ;
44use rustc_hir:: def_id:: LocalDefId ;
@@ -88,16 +88,18 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn {
8888 } ;
8989 cx. tcx . hir ( ) . visit_all_item_likes_in_crate ( & mut v) ;
9090
91- for usage in self . def_id_to_usage . values ( ) {
91+ for ( & def_id , usage) in & self . def_id_to_usage {
9292 let single_call_fn_span = usage. 0 ;
9393 if let [ caller_span] = * usage. 1 {
94- span_lint_and_help (
94+ span_lint_hir_and_then (
9595 cx,
9696 SINGLE_CALL_FN ,
97+ cx. tcx . local_def_id_to_hir_id ( def_id) ,
9798 single_call_fn_span,
9899 "this function is only used once" ,
99- Some ( caller_span) ,
100- "used here" ,
100+ |diag| {
101+ diag. span_help ( caller_span, "used here" ) ;
102+ } ,
101103 ) ;
102104 }
103105 }
Original file line number Diff line number Diff line change @@ -69,6 +69,17 @@ fn e() {
6969#[ test]
7070fn k ( ) { }
7171
72+ mod issue12182 {
73+ #[ allow( clippy:: single_call_fn) ]
74+ fn print_foo ( text : & str ) {
75+ println ! ( "{text}" ) ;
76+ }
77+
78+ fn use_print_foo ( ) {
79+ print_foo ( "foo" ) ;
80+ }
81+ }
82+
7283#[ test]
7384fn l ( ) {
7485 k ( ) ;
You can’t perform that action at this time.
0 commit comments