10000 Fix clippy lints by stphnt · Pull Request #213 · stphnt/zproto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix clippy lints #213

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 4 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ name = "binary"
required-features = ["binary"]

[lints.clippy]
cargo = "deny"
cargo = { level = "deny", priority = -1 }
# Some dependencies each have common dependencies but with different versions
# We cannot fix this, so ignore the lint.
multiple_crate_versions = { level = "allow", priority = 1 }
multiple_crate_versions = "allow"

pedantic = "deny"
pedantic = { level = "deny", priority = -1 }
# Pedantic group overrides
module_name_repetitions = { level = "allow", priority = 1 }
must_use_candidate = { level = "allow", priority = 1 } # too many
missing_errors_doc = { level = "allow", priority = 1 }
missing_panics_doc = { level = "allow", priority = 1 }
needless_pass_by_value = { level = "allow", priority = 1 }
module_name_repetitions = "allow"
must_use_candidate = "allow" # too many
missing_errors_doc = "allow"
missing_panics_doc = "allow"
needless_pass_by_value = "allow"

[lints.rust]
# groups
warnings = "deny"
rust-2018-idioms = "deny"
warnings = { level = "deny", priority = -1 }
rust-2018-idioms = { level = "deny", priority = -1 }

# individual lints
missing-docs = "deny"
Expand Down
10 changes: 5 additions & 5 deletions src/ascii/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub struct Axis<'a, Tag> {
/// The device address
address: NonZeroU8,
/// The axis number
axis: NonZeroU8,
number: NonZeroU8,
tag: std::marker::PhantomData<Tag>,
}

Expand All @@ -250,26 +250,26 @@ impl<Tag> Clone for Axis<'_, Tag> {
Axis {
info: self.info,
address: self.address,
axis: self.axis,
number: self.number,
tag: std::marker::PhantomData,
}
}
}

impl<'a, Tag> Axis<'a, Tag> {
/// Create an `Axis`
fn new(info: &'a ChainInfo, address: NonZeroU8, axis: NonZeroU8) -> Self {
fn new(info: &'a ChainInfo, address: NonZeroU8, number: NonZeroU8) -> Self {
Axis {
info,
address,
axis,
number,
tag: std::marker::PhantomData,
}
}

/// Get the [`Target`] for the axis.
pub fn target(&self) -> Target {
(self.address.get(), self.axis.get()).into()
(self.address.get(), self.number.get()).into()
}

/// Get access to this axis's settings.
Expand Down
14 changes: 6 additions & 8 deletions src/ascii/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1575,10 +1575,9 @@ fn do_something<Backend, Tag>(port: &mut Port<Backend, Tag>, chain: &Chain<Tag>)
where
H::PacketHandler: crate::convert::From<F>,
{
std::mem::replace(
self.handlers.packet(),
Some(crate::convert::From::from(callback)),
)
self.handlers
.packet()
.replace(crate::convert::From::from(callback))
}

/// Clear any callback registered via [`set_packet_handler`](Port::set_packet_handler) and return it.
Expand Down Expand Up @@ -1633,10 +1632,9 @@ fn do_something<Backend, Tag>(port: &mut Port<Backend, Tag>, chain: &Chain<Tag>)
where
H::UnexpectedAlertHandler: crate::convert::From<F>,
{
std::mem::replace(
self.handlers.unexpected_alert(),
Some(crate::convert::From::from(callback)),
)
self.handlers
.unexpected_alert()
.replace(crate::convert::From::from(callback))
}

/// Clear any callback registered via [`set_unexpected_alert_handler`](Port::set_unexpected_alert_handler) and return it.
Expand Down
7 changes: 3 additions & 4 deletions src/binary/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,9 @@ where
where
H::PacketHandler: crate::convert::From<F>,
{
std::mem::replace(
self.handlers.packet(),
Some(crate::convert::From::from(callback)),
)
self.handlers
.packet()
.replace(crate::convert::From::from(callback))
}

/// Clear any callback registered via [`set_packet_handler`](Port::set_packet_handler) and return it.
Expand Down
3 changes: 1 addition & 2 deletions src/timeout_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ impl<B: Backend, P: Port<B>> std::ops::Drop for TimeoutGuard<'_, B, P> {
.backend_mut()< 5E3C /span>
.set_read_timeout(self.original_timeout)
{
self.port.poison(io::Error::new(
io::ErrorKind::Other,
self.port.poison(io::Error::other(
if let Some(timeout) = self.original_timeout {
format!(
"failed to reset timeout to {} seconds: {}",
Expand Down
Loading
0