about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/min_rust_version_attr.rs
blob: 4627bef28a29bf35c41e92df36f8d9ce8e7f2522 (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
#![allow(clippy::redundant_clone)]
#![feature(custom_inner_attributes)]

fn main() {}

#[clippy::msrv = "1.42.0"]
fn just_under_msrv() {
    let log2_10 = 3.321928094887362;
}

#[clippy::msrv = "1.43.0"]
fn meets_msrv() {
    let log2_10 = 3.321928094887362;
    //~^ approx_constant
}

#[clippy::msrv = "1.44.0"]
fn just_above_msrv() {
    let log2_10 = 3.321928094887362;
    //~^ approx_constant
}

#[clippy::msrv = "1.42"]
fn no_patch_under() {
    let log2_10 = 3.321928094887362;
}

#[clippy::msrv = "1.43"]
fn no_patch_meets() {
    let log2_10 = 3.321928094887362;
    //~^ approx_constant
}

fn inner_attr_under() {
    #![clippy::msrv = "1.42"]
    let log2_10 = 3.321928094887362;
}

fn inner_attr_meets() {
    #![clippy::msrv = "1.43"]
    let log2_10 = 3.321928094887362;
    //~^ approx_constant
}

// https://github.com/rust-lang/rust-clippy/issues/6920
fn scoping() {
    mod m {
        #![clippy::msrv = "1.42.0"]
    }

    // Should warn
    let log2_10 = 3.321928094887362;
    //~^ approx_constant

    mod a {
        #![clippy::msrv = "1.42.0"]

        fn should_warn() {
            #![clippy::msrv = "1.43.0"]
            let log2_10 = 3.321928094887362;
            //~^ approx_constant
        }

        fn should_not_warn() {
            let log2_10 = 3.321928094887362;
        }
    }
}