summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.rs
blob: 21849a14fa95e3fde5a25bf83e744c4575ade43d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#![deny(clippy::index_refutable_slice)]

fn below_limit() {
    let slice: Option<&[u32]> = Some(&[1, 2, 3]);
    if let Some(slice) = slice {
        // This would usually not be linted but is included now due to the
        // index limit in the config file
        println!("{}", slice[7]);
    }
}

fn above_limit() {
    let slice: Option<&[u32]> = Some(&[1, 2, 3]);
    if let Some(slice) = slice {
        // This will not be linted as 8 is above the limit
        println!("{}", slice[8]);
    }
}

fn main() {
    below_limit();
    above_limit();
}