summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/single_call_fn.rs
blob: 3cc8061647dff4e5001c60811c39f99af74a1965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//@ignore-32bit
//@aux-build:proc_macros.rs
#![allow(clippy::redundant_closure_call, unused)]
#![warn(clippy::single_call_fn)]
#![no_main]

#[macro_use]
extern crate proc_macros;

// Do not lint since it's public
pub fn f() {}

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();
}

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();
}

#[test]
fn k() {}

#[test]
fn l() {
    k();
}