-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suggestion/fix to suspicious_open_options
Also rebase and fix conflicts
- Loading branch information
atwam
committed
Oct 26, 2023
1 parent
8e4475c
commit 928501e
Showing
6 changed files
with
56 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,7 @@ | ||
use std::fs::OpenOptions; | ||
#[allow(unused_must_use)] | ||
#[warn(clippy::suspicious_open_options)] | ||
fn main() { | ||
OpenOptions::new().create(true).truncate(true).open("foo.txt"); | ||
//~^ ERROR: file opened with `create`, but `truncate` behavior not defined | ||
} |
This file contains 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,7 @@ | ||
use std::fs::OpenOptions; | ||
#[allow(unused_must_use)] | ||
#[warn(clippy::suspicious_open_options)] | ||
fn main() { | ||
OpenOptions::new().create(true).open("foo.txt"); | ||
//~^ ERROR: file opened with `create`, but `truncate` behavior not defined | ||
} |
This file contains 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,12 @@ | ||
error: file opened with `create`, but `truncate` behavior not defined | ||
--> $DIR/open_options_fixable.rs:5:24 | ||
| | ||
LL | OpenOptions::new().create(true).open("foo.txt"); | ||
| ^^^^^^^^^^^^- help: add: `.truncate(true)` | ||
| | ||
= help: if you intend to overwrite an existing file entirely, call `.truncate(true)`. if you instead know that you may want to keep some parts of the old file, call `.truncate(false)` | ||
= note: `-D clippy::suspicious-open-options` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::suspicious_open_options)]` | ||
|
||
error: aborting due to previous error | ||
|