Skip to content
Open
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
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,9 @@ map_err_ignore = "allow"
map_unwrap_or = "allow"
match_wild_err_arm = "allow"
missing_fields_in_debug = "allow" # TODO: use finish_non_exhaustive
missing_panics_doc = "allow" # TODO: might be false
multiple_inherent_impl = "allow"
multiple_unsafe_ops_per_block = "allow"
needless_pass_by_value = "allow"
panic = "allow"
pattern_type_mismatch = "allow"
redundant_closure_for_method_calls = "allow"
redundant_else = "allow"
Expand Down
5 changes: 3 additions & 2 deletions src/client/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ where
/// # Errors
///
/// Returns an error if the connection encounters an error while being polled to completion.
#[allow(clippy::missing_panics_doc, reason="panic behavior consistent with future's existing invariant")]
pub async fn without_shutdown(self) -> crate::Result<Parts<T>> {
let mut conn = Some(self);
crate::common::future::poll_fn(move |cx| -> Poll<crate::Result<Parts<T>>> {
Expand Down Expand Up @@ -237,7 +238,7 @@ where
Ok(Ok(resp)) => Ok(resp),
Ok(Err(err)) => Err(err),
// this is definite bug if it happens, but it shouldn't happen!
Err(_canceled) => panic!("dispatch dropped without returning error"),
Err(_canceled) => unreachable!("dispatch dropped without returning error"),
},
Err(_req) => {
debug!("connection was not ready");
Expand Down Expand Up @@ -267,7 +268,7 @@ where
Ok(Ok(res)) => Ok(res),
Ok(Err(err)) => Err(err),
// this is definite bug if it happens, but it shouldn't happen!
Err(_) => panic!("dispatch dropped without returning error"),
Err(_) => unreachable!("dispatch dropped without returning error"),
},
Err(req) => {
debug!("connection was not ready");
Expand Down
4 changes: 2 additions & 2 deletions src/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ where
Ok(Ok(resp)) => Ok(resp),
Ok(Err(err)) => Err(err),
// this is definite bug if it happens, but it shouldn't happen!
Err(_canceled) => panic!("dispatch dropped without returning error"),
Err(_canceled) => unreachable!("dispatch dropped without returning error"),
},
Err(_req) => {
debug!("connection was not ready");
Expand Down Expand Up @@ -201,7 +201,7 @@ where
Ok(Ok(res)) => Ok(res),
Ok(Err(err)) => Err(err),
// this is definite bug if it happens, but it shouldn't happen!
Err(_) => panic!("dispatch dropped without returning error"),
Err(_) => unreachable!("dispatch dropped without returning error"),
},
Err(req) => {
debug!("connection was not ready");
Expand Down
1 change: 1 addition & 0 deletions src/common/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) trait LockResultExt<T> {
fn panic_if_poisoned(self) -> T;
}

#[allow(clippy::panic)]
impl<T> LockResultExt<T> for LockResult<T> {
#[track_caller]
fn panic_if_poisoned(self) -> T {
Expand Down
7 changes: 7 additions & 0 deletions src/common/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl Time {
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
pub(crate) fn sleep(&self, duration: Duration) -> Pin<Box<dyn Sleep>> {
match &self {
#[allow(clippy::panic, reason = "Reachable only through user misconfiguration")]
Time::Empty => {
panic!("You must supply a timer.")
}
Expand All @@ -43,6 +44,7 @@ impl Time {
#[cfg(all(feature = "server", feature = "http1"))]
pub(crate) fn sleep_until(&self, deadline: Instant) -> Pin<Box<dyn Sleep>> {
match &self {
#[allow(clippy::panic, reason = "Reachable only through user misconfiguration")]
Time::Empty => {
panic!("You must supply a timer.")
}
Expand All @@ -59,6 +61,7 @@ impl Time {

pub(crate) fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
match &self {
#[allow(clippy::panic, reason = "Reachable only through user misconfiguration")]
Time::Empty => {
panic!("You must supply a timer.")
}
Expand All @@ -77,6 +80,10 @@ impl Time {
Time::Timer(..) => Some(dur),
},
Dur::Configured(Some(dur)) => match self {
#[allow(
clippy::panic,
reason = "Reachable only through user misconfiguration."
)]
Time::Empty => panic!("timeout `{name}` set, but no timer set",),
Time::Timer(..) => Some(dur),
},
Expand Down
6 changes: 5 additions & 1 deletion src/ext/h1_reason_phrase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ impl ReasonPhrase {
}

/// Converts a static byte slice to a reason phrase.
///
/// # Panics
///
/// This method will panic if 'reason' contains an invalid byte. In a const context,
/// this is a compile-time error instead.
pub const fn from_static(reason: &'static [u8]) -> Self {
// TODO: this can be made const once MSRV is >= 1.57.0
assert!(
find_invalid_byte(reason).is_none(),
"invalid byte in static reason phrase"
Expand Down
2 changes: 2 additions & 0 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ impl Http1Transaction for Server {
debug!("response with HTTP2 version coerced to HTTP/1.1");
extend(dst, b"HTTP/1.1 ");
}
#[allow(clippy::panic, reason="Only reachable if the caller sets an usnupported version on the request.")]
other => panic!("unexpected response version: {other:?}"),
}

Expand Down Expand Up @@ -1221,6 +1222,7 @@ impl Http1Transaction for Client {
debug!("request with HTTP2 version coerced to HTTP/1.1");
extend(dst, b"HTTP/1.1");
}
#[allow(clippy::panic, reason="Only reachable if the caller sets an usnupported version on the request.")]
other => panic!("unexpected request version: {other:?}"),
}
extend(dst, b"\r\n");
Expand Down
5 changes: 5 additions & 0 deletions src/rt/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ impl ReadBufCursor<'_> {
/// # Safety
///
/// The caller must take care that `n` more bytes have been initialized.
///
/// # Panics
///
/// This method will panic if advancing would cause the filled cursor to
/// overflow `usize`.
#[inline]
pub unsafe fn advance(&mut self, n: usize) {
self.buf.filled = self.buf.filled.checked_add(n).expect("overflow");
Expand Down
1 change: 1 addition & 0 deletions src/server/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ where
/// # Error
///
/// This errors if the underlying connection protocol is not HTTP/1.
#[allow(clippy::missing_panics_doc, reason="All futures share similar panic behavior when polled after completion")]
pub fn without_shutdown(self) -> impl Future<Output = crate::Result<Parts<I, S>>> {
let mut zelf = Some(self);
crate::common::future::poll_fn(move |cx| {
Expand Down