summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/permissions_set_readonly_false.rs
blob: 28c00d100942cfebe4794987a9e4677ce982bf81 (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
#![allow(unused)]
#![warn(clippy::permissions_set_readonly_false)]

use std::fs::File;

struct A;

impl A {
    pub fn set_readonly(&mut self, b: bool) {}
}

fn set_readonly(b: bool) {}

fn main() {
    let f = File::create("foo.txt").unwrap();
    let metadata = f.metadata().unwrap();
    let mut permissions = metadata.permissions();
    // lint here
    permissions.set_readonly(false);
    // no lint
    permissions.set_readonly(true);

    let mut a = A;
    // no lint here - a is not of type std::fs::Permissions
    a.set_readonly(false);

    // no lint here - plain function
    set_readonly(false);
}