Fix conflicts
- New ineffective_open_options had to be fixed. - Now not raising an issue on missing `truncate` when `append(true)` makes the intent clear. - Try implementing more advanced tests for non-chained operations. Fail
This commit is contained in:
parent
84588a8815
commit
515fe65ba8
5 changed files with 44 additions and 12 deletions
|
|
@ -26,16 +26,23 @@ fn main() {
|
|||
.unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.append(false)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(false)
|
||||
.append(false)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
let file = OpenOptions::new().create(true).append(true).open("dump.json").unwrap();
|
||||
let file = OpenOptions::new().create(true).write(true).open("dump.json").unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,16 +26,23 @@ fn main() {
|
|||
.unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.append(false)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(false)
|
||||
.append(false)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
let file = OpenOptions::new().create(true).append(true).open("dump.json").unwrap();
|
||||
let file = OpenOptions::new().create(true).write(true).open("dump.json").unwrap();
|
||||
let file = OpenOptions::new()
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.write(true)
|
||||
.open("dump.json")
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,5 +29,6 @@ fn main() {
|
|||
let mut options = std::fs::OpenOptions::new();
|
||||
options.read(true);
|
||||
options.read(false);
|
||||
//~^ ERROR: the method `read` is called more than once
|
||||
//#~^ ERROR: the method `read` is called more than once
|
||||
options.open("foo.txt");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ error: file opened with `create`, but `truncate` behavior not defined
|
|||
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)`
|
||||
= 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)`. Alternatively, use `.append` to append to the file instead of overwriting it.
|
||||
= 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
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue