]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/filetype_is_file.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / filetype_is_file.rs
CommitLineData
f20569fa
XL
1#![warn(clippy::filetype_is_file)]
2
3fn main() -> std::io::Result<()> {
4 use std::fs;
5 use std::ops::BitOr;
6
7 // !filetype.is_dir()
8 if fs::metadata("foo.txt")?.file_type().is_file() {
9 // read file
10 }
11
12 // positive of filetype.is_dir()
13 if !fs::metadata("foo.txt")?.file_type().is_file() {
14 // handle dir
15 }
16
17 // false positive of filetype.is_dir()
18 if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) {
19 // ...
20 }
21
22 Ok(())
23}