-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix issue4503 #4543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix issue4503 #4543
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3a78845
Add test.
xiongmao86 96334d0
Declare lint.
xiongmao86 3c59eaf
Add lint logic.
xiongmao86 a1f8135
format codebase.
xiongmao86 bf9e6ca
Fix lint warning in compile-test.rs
xiongmao86 8d333a3
Extend spans to include !.
xiongmao86 a73822d
Fix documents and messages.
xiongmao86 2909bc3
./util/dev update_lints.
xiongmao86 8d3cc6b
Change lint message.
xiongmao86 1018b78
Update clippy_lints/src/methods/mod.rs
xiongmao86 77c48ca
Fix grammar error.
xiongmao86 2b477f3
Update lints again.
xiongmao86 bba4688
Pull master, rebase, and update_lints again.
xiongmao86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![warn(clippy::filetype_is_file)] | ||
|
||
fn main() -> std::io::Result<()> { | ||
use std::fs; | ||
use std::ops::BitOr; | ||
|
||
// !filetype.is_dir() | ||
if fs::metadata("foo.txt")?.file_type().is_file() { | ||
flip1995 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// read file | ||
} | ||
|
||
// positive of filetype.is_dir() | ||
if !fs::metadata("foo.txt")?.file_type().is_file() { | ||
// handle dir | ||
} | ||
|
||
// false positive of filetype.is_dir() | ||
if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { | ||
// ... | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error: `FileType::is_file()` only covers regular files | ||
--> $DIR/filetype_is_file.rs:8:8 | ||
| | ||
LL | if fs::metadata("foo.txt")?.file_type().is_file() { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::filetype-is-file` implied by `-D warnings` | ||
= help: use `!FileType::is_dir()` instead | ||
|
||
error: `!FileType::is_file()` only denies regular files | ||
--> $DIR/filetype_is_file.rs:13:8 | ||
| | ||
LL | if !fs::metadata("foo.txt")?.file_type().is_file() { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: use `FileType::is_dir()` instead | ||
|
||
error: `FileType::is_file()` only covers regular files | ||
--> $DIR/filetype_is_file.rs:18:9 | ||
| | ||
LL | if !fs::metadata("foo.txt")?.file_type().is_file().bitor(true) { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: use `!FileType::is_dir()` instead | ||
|
||
error: aborting due to 3 previous errors | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.