Skip to content

Commit

Permalink
Fix all clippy and rustc warnings (beta toolchain version 0.1.77)
Browse files Browse the repository at this point in the history
The `suspicious_open_options` lint [0] warns that the truncation
behaviour should be made explicit when creating new files. We also set
`create_new(true)`, which ensures that a new file will *always* be
created so we should simply drop `create(true)` since it has no effect
anyway: "If `.create_new(true)` is set, `.create()` and `.truncate()`
are ignored." [1]

The `unconditional_recursion` lint [2] also emits a warning but that's a
false positive and should already be fixed in nightly (see [3] for a
very similar case and [4] for the PR that should fix it).
In our case we're comparing tuples with just two fields of the `Package`
structure so it isn't recursive.

[0]: https://rust-lang.github.io/rust-clippy/master/index.html#/suspicious_open_options
[1]: https://docs.rs/tokio/1.34.0/tokio/fs/struct.OpenOptions.html#method.create_new
[2]: https://rust-lang.github.io/rust-clippy/master/index.html#/unconditional_recursion
[3]: rust-lang/rust-clippy#12133
[4]: rust-lang/rust-clippy#12137

Signed-off-by: Michael Weiss <michael.weiss@eviden.com>
  • Loading branch information
primeos-work authored and ammernico committed Apr 30, 2024
1 parent 6890913 commit 8327fa9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/endpoint/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ impl<'a> LogReceiver<'a> {
self.job.uuid()
));
tokio::fs::OpenOptions::new()
.create(true)
.create_new(true)
.write(true)
.open(&path)
Expand Down
2 changes: 2 additions & 0 deletions src/package/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ impl<'a> std::fmt::Debug for DebugPackage<'a> {
}

impl PartialEq for Package {
// Ignore the following lint as it results in a false positive with clippy 0.1.77:
#[allow(clippy::unconditional_recursion)]
fn eq(&self, other: &Package) -> bool {
(self.name(), self.version()).eq(&(other.name(), other.version()))
}
Expand Down
1 change: 0 additions & 1 deletion src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ impl SourceEntry {

trace!("Creating file now: {}", p.display());
tokio::fs::OpenOptions::new()
.create(true)
.create_new(true)
.write(true)
.open(&p)
Expand Down

0 comments on commit 8327fa9

Please sign in to comment.