about summary refs log tree commit diff
path: root/tests/ui/lint/fn-ptr-comparisons-weird.rs
blob: 4d756cb49df0f95ba3b62afe557e905fabc7f6ee (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
//@ check-pass

#[derive(PartialEq, Eq)]
struct A {
    f: fn(),
    //~^ WARN function pointer comparisons
}

#[allow(unpredictable_function_pointer_comparisons)]
#[derive(PartialEq, Eq)]
struct AllowedAbove {
    f: fn(),
}

#[derive(PartialEq, Eq)]
#[allow(unpredictable_function_pointer_comparisons)]
struct AllowedBelow {
    f: fn(),
}

fn main() {
    let f: fn() = main;
    let g: fn() = main;

    let _ = f > g;
    //~^ WARN function pointer comparisons
    let _ = f >= g;
    //~^ WARN function pointer comparisons
    let _ = f <= g;
    //~^ WARN function pointer comparisons
    let _ = f < g;
    //~^ WARN function pointer comparisons
    let _ = assert_eq!(g, g);
    //~^ WARN function pointer comparisons
    let _ = assert_ne!(g, g);
    //~^ WARN function pointer comparisons
}