2022-10-28 20:07:17 +00:00
|
|
|
#![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);
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: call to `set_readonly` with argument `false`
|
|
|
|
//~| NOTE: on Unix platforms this results in the file being world writable
|
2022-10-28 20:07:17 +00:00
|
|
|
// 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);
|
|
|
|
}
|