2024-08-17 14:38:10 -05:00
|
|
|
//@ignore-bitwidth: 32
|
2023-07-27 08:23:04 -05:00
|
|
|
//@aux-build:proc_macros.rs
|
2023-06-14 07:16:56 -05:00
|
|
|
#![allow(clippy::redundant_closure_call, unused)]
|
2023-06-14 06:48:34 -05:00
|
|
|
#![warn(clippy::single_call_fn)]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate proc_macros;
|
|
|
|
|
|
|
|
// Do not lint since it's public
|
|
|
|
pub fn f() {}
|
|
|
|
|
2023-06-14 07:16:56 -05:00
|
|
|
fn i() {}
|
|
|
|
fn j() {}
|
|
|
|
|
|
|
|
fn h() {
|
|
|
|
// Linted
|
|
|
|
let a = i;
|
|
|
|
// Do not lint closures
|
|
|
|
let a = (|| {
|
|
|
|
// Not linted
|
|
|
|
a();
|
|
|
|
// Imo, it's reasonable to lint this as the function is still only being used once. Just in
|
|
|
|
// a closure.
|
|
|
|
j();
|
|
|
|
});
|
|
|
|
a();
|
|
|
|
}
|
|
|
|
|
2023-06-14 06:48:34 -05:00
|
|
|
fn g() {
|
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn c() {
|
|
|
|
println!("really");
|
|
|
|
println!("long");
|
|
|
|
println!("function...");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn d() {
|
|
|
|
c();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn a() {}
|
|
|
|
|
|
|
|
fn b() {
|
|
|
|
a();
|
|
|
|
|
|
|
|
external! {
|
|
|
|
fn lol() {
|
|
|
|
lol_inner();
|
|
|
|
}
|
|
|
|
fn lol_inner() {}
|
|
|
|
}
|
|
|
|
with_span! {
|
|
|
|
span
|
|
|
|
fn lol2() {
|
|
|
|
lol2_inner();
|
|
|
|
}
|
|
|
|
fn lol2_inner() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn e() {
|
|
|
|
b();
|
|
|
|
b();
|
|
|
|
}
|
2023-06-17 20:00:36 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn k() {}
|
|
|
|
|
2024-01-21 07:54:01 -06:00
|
|
|
mod issue12182 {
|
|
|
|
#[allow(clippy::single_call_fn)]
|
|
|
|
fn print_foo(text: &str) {
|
|
|
|
println!("{text}");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn use_print_foo() {
|
|
|
|
print_foo("foo");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-17 20:00:36 -05:00
|
|
|
#[test]
|
|
|
|
fn l() {
|
|
|
|
k();
|
|
|
|
}
|
2024-01-21 09:40:06 -06:00
|
|
|
|
|
|
|
trait Trait {
|
|
|
|
fn default() {}
|
|
|
|
fn foo(&self);
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
// test some kind of foreign item
|
|
|
|
fn rand() -> std::ffi::c_int;
|
|
|
|
}
|
|
|
|
fn m<T: Trait>(v: T) {
|
|
|
|
const NOT_A_FUNCTION: i32 = 1;
|
|
|
|
let _ = NOT_A_FUNCTION;
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
impl S {
|
|
|
|
fn foo() {}
|
|
|
|
}
|
|
|
|
T::default();
|
|
|
|
S::foo();
|
|
|
|
v.foo();
|
|
|
|
unsafe { rand() };
|
|
|
|
}
|