Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
id: rust-toolchain
with:
toolchain: "1.77"
toolchain: "1.93"
components: clippy

- uses: actions/cache@v4
Expand Down
2 changes: 2 additions & 0 deletions examples/websocket/src/ws.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::type_complexity)]

use base64::prelude::*;
use gotham::hyper::header::{
HeaderValue, CONNECTION, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_KEY, UPGRADE,
Expand Down
18 changes: 9 additions & 9 deletions gotham/src/extractor/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) enum ExtractorError {
/// The `PathExtractor` type is not one which can be deserialized from a
/// `ExtractorDeserializer`. This deserializer requires a structured type (usually a custom
/// struct) which can be deserialized from key / value pairs.
UnexpectedTargetType(&'static str),
UnexpectedTargetType(#[allow(dead_code)] &'static str),

/// An invalid state occurred wherein a "key" (i.e. the name of a route segment) was
/// deserialized as something other than an `identifier`.
Expand All @@ -38,7 +38,7 @@ pub(crate) enum ExtractorError {
/// Attempting to deserialize a value into a struct is one example where this error will be
/// triggered, since a list of `0..n` values can't be converted into key/value pairs for
/// mapping into the struct fields.
UnexpectedValueType(&'static str),
UnexpectedValueType(#[allow(dead_code)] &'static str),

/// The enum variant is not able to be deserialized from the value, because the variant is not
/// of the correct type. Only unit variants are supported - that is, enum variants with no data
Expand All @@ -59,7 +59,7 @@ pub(crate) enum ExtractorError {
/// #
/// # fn main() {}
/// ```
UnexpectedEnumVariantType(&'static str),
UnexpectedEnumVariantType(#[allow(dead_code)] &'static str),

/// An invalid internal state occurred where a segment mapping had no values. This should never
/// occur because the presence of a key implies the presence of a value.
Expand All @@ -76,12 +76,12 @@ pub(crate) enum ExtractorError {
/// An error occurred while parsing a string into a value type for one of the fields. For
/// example, in a route for `/resource/:id`, and with `id: i32` in the `PathExtractor` struct,
/// a request for `/resource/abc` would result in a parse error trying to convert to `i32`.
ParseError(String),
ParseError(#[allow(dead_code)] String),

/// An error occurred, and a `Deserialize` impl provided a custom error message. This is used
/// in the implementation of the `serde::de::Error` trait for external types to provide
/// informative error messages.
Custom(String),
Custom(#[allow(dead_code)] String),
}

impl Display for ExtractorError {
Expand Down Expand Up @@ -766,8 +766,8 @@ mod tests {
assert_eq!(p.u16_val, 40511);
assert_eq!(p.u32_val, 4_000_000_000);
assert_eq!(p.u64_val, 9_000_000_000);
assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
assert!((p.f32_val - 1.4).abs() < f32::EPSILON);
assert!((p.f64_val - 2.6).abs() < f64::EPSILON);
assert_eq!(p.string_val, "this is an owned string");
assert_eq!(p.char_val, 'a');
assert_eq!(p.optional_val, Some("this is optional".to_owned()));
Expand Down Expand Up @@ -845,8 +845,8 @@ mod tests {
assert_eq!(p.u16_val, 40511);
assert_eq!(p.u32_val, 4_000_000_000);
assert_eq!(p.u64_val, 9_000_000_000);
assert!((p.f32_val - 1.4).abs() < std::f32::EPSILON);
assert!((p.f64_val - 2.6).abs() < std::f64::EPSILON);
assert!((p.f32_val - 1.4).abs() < f32::EPSILON);
assert!((p.f64_val - 2.6).abs() < f64::EPSILON);
assert_eq!(p.string_val, "this is an owned string");
assert_eq!(p.char_val, 'a');
assert_eq!(p.optional_val, Some("this is optional".to_owned()));
Expand Down
4 changes: 2 additions & 2 deletions gotham/src/handler/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::state::{FromState, State, StateData};

use std::convert::From;
use std::fs::Metadata;
use std::io::{ErrorKind, SeekFrom};
use std::io::SeekFrom;
use std::iter::FromIterator;
use std::mem::MaybeUninit;
use std::path::{Component, Path, PathBuf};
Expand Down Expand Up @@ -264,7 +264,7 @@ fn create_file_response(options: FileOptions, state: State) -> Pin<Box<HandlerFu
);
response = response.status(StatusCode::PARTIAL_CONTENT).header(
CONTENT_RANGE,
HeaderValue::from_str(&val).map_err(|e| io::Error::new(ErrorKind::Other, e))?,
HeaderValue::from_str(&val).map_err(io::Error::other)?,
);
}

Expand Down
9 changes: 5 additions & 4 deletions gotham/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ async fn tcp_listener<A>(addr: A) -> io::Result<TcpListener>
where
A: ToSocketAddrs + 'static,
{
let addr = addr.to_socket_addrs()?.next().ok_or_else(|| {
io::Error::new(io::ErrorKind::Other, "unable to resolve listener address")
})?;
let addr = addr
.to_socket_addrs()?
.next()
.ok_or_else(|| io::Error::other("unable to resolve listener address"))?;
TcpListener::bind(addr).await
}

Expand All @@ -109,7 +110,7 @@ where
/// support. The wrap argument is a function that will receive a tokio-io TcpStream and should wrap
/// the socket as necessary. Errors returned by this function will be ignored and the connection
/// will be dropped if the future returned by the wrapper resolves to an error.
pub async fn bind_server<'a, NH, F, Wrapped, Wrap>(
pub async fn bind_server<NH, F, Wrapped, Wrap>(
listener: TcpListener,
new_handler: NH,
wrap: Wrap,
Expand Down
5 changes: 1 addition & 4 deletions gotham/src/middleware/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,7 @@ where
e
);

let e = io::Error::new(
io::ErrorKind::Other,
format!("backend failed to return session: {:?}", e),
);
let e = io::Error::other(format!("backend failed to return session: {:?}", e));

future::err((state, e.into()))
}
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/router/route/matcher/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl core::str::FromStr for QMime {
/// headers.insert(ACCEPT, "application/json".parse().unwrap());
/// state.put(headers);
/// assert!(matcher.is_match(&state).is_ok());
///
/// // Accept header of `image/*`
/// let mut headers = HeaderMap::new();
/// headers.insert(ACCEPT, "image/*".parse().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/router/route/matcher/lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) trait LookupTableFromTypes {

fn insert<T>(into: &mut LookupTable, key: T, value: usize)
where
T: Into<String> + ?Sized,
T: Into<String>,
{
into.entry(key.into()).or_default().push(value);
}
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/router/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Tree {
pub(crate) fn traverse<'a>(
&'a self,
req_path_segments: &'a [PercentDecoded],
) -> Option<(&Node, SegmentMapping<'a>, usize)> {
) -> Option<(&'a Node, SegmentMapping<'a>, usize)> {
trace!(" starting tree traversal");
self.root.match_node(req_path_segments)
}
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/router/tree/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Eq for ConstrainedSegmentRegex {}

impl PartialOrd for ConstrainedSegmentRegex {
fn partial_cmp(&self, other: &ConstrainedSegmentRegex) -> Option<Ordering> {
Some(self.as_str().cmp(other.as_str()))
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion gotham/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl State {
T: StateData,
{
let type_id = TypeId::of::<T>();
self.data.get(&type_id).is_some()
self.data.contains_key(&type_id)
}

/// Tries to borrow a value from the `State` storage.
Expand Down
3 changes: 2 additions & 1 deletion gotham/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl Server for Arc<TestServerData> {
.block_on(future)
}

#[allow(clippy::readonly_write_lock)]
fn request_expiry(&self) -> Sleep {
let runtime = self.runtime.write().unwrap();
let _guard = runtime.enter();
Expand Down Expand Up @@ -529,7 +530,7 @@ pub(crate) mod common_tests {

let content_length = {
let content_length = res.headers().get(CONTENT_LENGTH).expect("ContentLength");
assert_eq!(content_length, &format!("{}", data.as_bytes().len()));
assert_eq!(content_length, &format!("{}", data.len()));
content_length.clone()
};

Expand Down
Loading