Skip to content

Commit cf563e8

Browse files
authored
style(lib): enforce clippy::unnested_or_patterns (#4256)
see #4071. Lint doc: https://clippy.rust-lang.org/master/index.html#unnested_or_patterns The rule rewrites patterns in disjunctive normal form (DNF) into conjunctive normal form (CNF). Four patterns were flagged by this rule, which were replaced with equivalent nested ones.
1 parent 8abd0b4 commit cf563e8

5 files changed

Lines changed: 6 additions & 8 deletions

File tree

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ needless_pass_by_value = "allow"
127127
pattern_type_mismatch = "allow"
128128
redundant_else = "allow"
129129
struct_excessive_bools = "allow" # TODO: bogus lint?
130-
unnested_or_patterns = "allow"
131130
unused_async = "allow" # TODO: is it for API?
132131
unused_trait_names = "allow" # TODO: kinda annoying, but might be good to deny
133132
unwrap_in_result = "allow"

‎src/body/length.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl DecodedLength {
6868
))]
6969
pub(crate) fn sub_if(&mut self, amt: u64) {
7070
match self {
71-
&mut DecodedLength::CHUNKED | &mut DecodedLength::CLOSE_DELIMITED => (),
71+
&mut (DecodedLength::CHUNKED | DecodedLength::CLOSE_DELIMITED) => (),
7272
DecodedLength(known) => {
7373
*known -= amt;
7474
}

‎src/error.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl Error {
193193
pub fn is_parse_too_large(&self) -> bool {
194194
matches!(
195195
self.inner.kind,
196-
Kind::Parse(Parse::TooLarge) | Kind::Parse(Parse::UriTooLong)
196+
Kind::Parse(Parse::TooLarge | Parse::UriTooLong)
197197
)
198198
}
199199

‎src/proto/h1/role.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,9 @@ impl Http1Transaction for Server {
493493
fn on_error(err: &crate::Error) -> Option<MessageHead<Self::Outgoing>> {
494494
use crate::error::Kind;
495495
let status = match *err.kind() {
496-
Kind::Parse(Parse::Method)
497-
| Kind::Parse(Parse::Header(_))
498-
| Kind::Parse(Parse::Uri)
499-
| Kind::Parse(Parse::Version) => StatusCode::BAD_REQUEST,
496+
Kind::Parse(Parse::Method | Parse::Header(_) | Parse::Uri | Parse::Version) => {
497+
StatusCode::BAD_REQUEST
498+
}
500499
Kind::Parse(Parse::TooLarge) => StatusCode::REQUEST_HEADER_FIELDS_TOO_LARGE,
501500
Kind::Parse(Parse::UriTooLong) => StatusCode::URI_TOO_LONG,
502501
_ => return None,

‎src/proto/h2/upgrade.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Read for H2Upgraded {
179179
}
180180
Some(Err(e)) => {
181181
return Poll::Ready(match e.reason() {
182-
Some(Reason::NO_ERROR) | Some(Reason::CANCEL) => Ok(()),
182+
Some(Reason::NO_ERROR | Reason::CANCEL) => Ok(()),
183183
Some(Reason::STREAM_CLOSED) => {
184184
Err(std::io::Error::new(std::io::ErrorKind::BrokenPipe, e))
185185
}

0 commit comments

Comments
 (0)