File tree 2 files changed +18
-5
lines changed
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 ;
2
2
use clippy_utils:: { is_from_proc_macro, is_in_test_function} ;
3
3
use rustc_data_structures:: fx:: FxHashMap ;
4
4
use rustc_hir:: def_id:: LocalDefId ;
@@ -88,16 +88,18 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn {
88
88
} ;
89
89
cx. tcx . hir ( ) . visit_all_item_likes_in_crate ( & mut v) ;
90
90
91
- for usage in self . def_id_to_usage . values ( ) {
91
+ for ( & def_id , usage) in & self . def_id_to_usage {
92
92
let single_call_fn_span = usage. 0 ;
93
93
if let [ caller_span] = * usage. 1 {
94
- span_lint_and_help (
94
+ span_lint_hir_and_then (
95
95
cx,
96
96
SINGLE_CALL_FN ,
97
+ cx. tcx . local_def_id_to_hir_id ( def_id) ,
97
98
single_call_fn_span,
98
99
"this function is only used once" ,
99
- Some ( caller_span) ,
100
- "used here" ,
100
+ |diag| {
101
+ diag. span_help ( caller_span, "used here" ) ;
102
+ } ,
101
103
) ;
102
104
}
103
105
}
Original file line number Diff line number Diff line change @@ -69,6 +69,17 @@ fn e() {
69
69
#[ test]
70
70
fn k ( ) { }
71
71
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
+
72
83
#[ test]
73
84
fn l ( ) {
74
85
k ( ) ;
You can’t perform that action at this time.
0 commit comments