Skip to content

Commit ecf2129

Browse files
authored
Correctly run clippy on sub-crates (#9398)
1 parent 1336f17 commit ecf2129

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

noxfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ def rust(session: nox.Session) -> None:
188188

189189
with session.chdir("src/rust/"):
190190
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
191-
session.run("cargo", "clippy", "--", "-D", "warnings", external=True)
191+
session.run(
192+
"cargo", "clippy", "--all", "--", "-D", "warnings", external=True
193+
)
192194

193195
build_output = session.run(
194196
"cargo",

src/rust/cryptography-x509-validation/src/types.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ impl<'a> DNSPattern<'a> {
113113
}
114114
}
115115

116-
#[derive(Copy, Clone, Debug, PartialEq)]
116+
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
117117
pub struct IPAddress(IpAddr);
118118

119119
/// An `IPAddress` represents an IP address as defined in [RFC 5280 4.2.1.6].
120120
///
121121
/// [RFC 5280 4.2.1.6]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.6
122122
impl IPAddress {
123+
#[allow(clippy::should_implement_trait)]
123124
pub fn from_str(s: &str) -> Option<Self> {
124125
IpAddr::from_str(s).ok().map(Self::from)
125126
}
@@ -175,7 +176,7 @@ impl IPAddress {
175176
pub fn mask(&self, prefix: u8) -> Self {
176177
match self.0 {
177178
IpAddr::V4(a) => {
178-
let prefix = 32u8.checked_sub(prefix).unwrap_or(0).into();
179+
let prefix = 32u8.saturating_sub(prefix).into();
179180
let masked = u32::from_be_bytes(a.octets())
180181
& u32::MAX
181182
.checked_shr(prefix)
@@ -185,7 +186,7 @@ impl IPAddress {
185186
Self::from_bytes(&masked.to_be_bytes()).unwrap()
186187
}
187188
IpAddr::V6(a) => {
188-
let prefix = 128u8.checked_sub(prefix).unwrap_or(0).into();
189+
let prefix = 128u8.saturating_sub(prefix).into();
189190
let masked = u128::from_be_bytes(a.octets())
190191
& u128::MAX
191192
.checked_shr(prefix)
@@ -204,7 +205,7 @@ impl From<IpAddr> for IPAddress {
204205
}
205206
}
206207

207-
#[derive(Debug, PartialEq)]
208+
#[derive(Debug, PartialEq, Eq)]
208209
pub struct IPRange {
209210
address: IPAddress,
210211
prefix: u8,

0 commit comments

Comments
 (0)