[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix rust edition idioms (seanmonstar#898)
Browse files Browse the repository at this point in the history
* Fix rust edition idioms

* Remove dead code

* Force rust edition idioms
  • Loading branch information
nickelc committed Sep 13, 2021
1 parent 79e7bba commit eba6477
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 74 deletions.
1 change: 0 additions & 1 deletion examples/autoreload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use listenfd::ListenFd;
use std::convert::Infallible;
use warp::Filter;

extern crate listenfd;
/// You'll need to install `systemfd` and `cargo-watch`:
/// ```
/// cargo install systemfd cargo-watch
Expand Down
2 changes: 1 addition & 1 deletion examples/handlebars_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct WithTemplate<T: Serialize> {
value: T,
}

fn render<T>(template: WithTemplate<T>, hbs: Arc<Handlebars>) -> impl warp::Reply
fn render<T>(template: WithTemplate<T>, hbs: Arc<Handlebars<'_>>) -> impl warp::Reply
where
T: Serialize,
{
Expand Down
8 changes: 4 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ impl Error {
}

impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Skip showing worthless `Error { .. }` wrapper.
fmt::Debug::fmt(&self.inner, f)
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.inner, f)
}
}
Expand Down Expand Up @@ -63,13 +63,13 @@ macro_rules! unit_error {
$pub struct $typ { _p: (), }

impl ::std::fmt::Debug for $typ {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.debug_struct(stringify!($typ)).finish()
}
}

impl ::std::fmt::Display for $typ {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str($display)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/filter/and.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
<U::Error as CombineRejection<T::Error>>::One,
>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().state.poll(cx)
}
}
Expand All @@ -76,7 +76,7 @@ where
{
type Output = Result<CombinedTuples<TE, U::Extract>, <U::Error as CombineRejection<E>>::One>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
match self.as_mut().project() {
StateProj::First(first, second) => {
Expand Down
4 changes: 2 additions & 2 deletions src/filter/and_then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
<<F::Output as TryFuture>::Error as CombineRejection<T::Error>>::One,
>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().state.poll(cx)
}
}
Expand All @@ -87,7 +87,7 @@ where
<<F::Output as TryFuture>::Error as CombineRejection<T::Error>>::One,
>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
match self.as_mut().project() {
StateProj::First(first, second) => {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<T: Tuple> Clone for BoxedFilter<T> {
}

impl<T: Tuple> fmt::Debug for BoxedFilter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BoxedFilter").finish()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/filter/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
type Output = Result<(F::Output,), T::Error>;

#[inline]
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let pin = self.project();
match ready!(pin.extract.try_poll(cx)) {
Ok(ex) => {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/map_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ where
type Output = Result<T::Extract, E>;

#[inline]
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.as_mut()
.project()
.extract
Expand Down
2 changes: 1 addition & 1 deletion src/filter/or.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
{
type Output = Result<(Either<T::Extract, U::Extract>,), Combined<U::Error, T::Error>>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
let pin = self.as_mut().project();
let (err1, fut2) = match pin.state.project() {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/or_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
{
type Output = Result<<F::Output as TryFuture>::Ok, <F::Output as TryFuture>::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
let pin = self.as_mut().project();
let (err, second) = match pin.state.project() {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
<F::Output as TryFuture>::Error,
>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
let pin = self.as_mut().project();
let (err, second) = match pin.state.project() {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
type Output = Result<Response, Infallible>;

#[inline]
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
debug_assert!(!route::is_set(), "nested route::set calls");

let pin = self.project();
Expand Down
4 changes: 2 additions & 2 deletions src/filter/then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
{
type Output = Result<(<F::Output as Future>::Output,), T::Error>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().state.poll(cx)
}
}
Expand All @@ -75,7 +75,7 @@ where
{
type Output = Result<(<F::Output as Future>::Output,), T::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
loop {
match self.as_mut().project() {
StateProj::First(first, second) => {
Expand Down
2 changes: 1 addition & 1 deletion src/filter/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
type Output = Result<T, F::Error>;

#[inline]
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(match ready!(self.project().inner.try_poll(cx))? {
(Either::A(x),) | (Either::B(x),) => Ok(x),
})
Expand Down
2 changes: 1 addition & 1 deletion src/filter/untuple_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
type Output = Result<T, F::Error>;

#[inline]
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match ready!(self.project().extract.try_poll(cx)) {
Ok((t,)) => Poll::Ready(Ok(t)),
Err(err) => Poll::Ready(Err(err)),
Expand Down
2 changes: 1 addition & 1 deletion src/filters/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Future for AnyFut {
type Output = Result<(), Infallible>;

#[inline]
fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(Ok(()))
}
}
6 changes: 3 additions & 3 deletions src/filters/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct BodyStream {
impl Stream for BodyStream {
type Item = Result<Bytes, crate::Error>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let opt_item = ready!(Pin::new(&mut self.get_mut().body).poll_next(cx));

match opt_item {
Expand All @@ -318,7 +318,7 @@ pub struct BodyDeserializeError {
}

impl fmt::Display for BodyDeserializeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Request body deserialize error: {}", self.cause)
}
}
Expand All @@ -333,7 +333,7 @@ impl StdError for BodyDeserializeError {
pub(crate) struct BodyReadError(::hyper::Error);

impl ::std::fmt::Display for BodyReadError {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "Request body read error: {}", self.0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/filters/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ mod internal {
{
type Output = Result<(Compressed,), F::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let pin = self.as_mut().project();
let result = ready!(pin.future.try_poll(cx));
match result {
Expand Down
6 changes: 3 additions & 3 deletions src/filters/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,13 @@ enum Forbidden {
}

impl ::std::fmt::Debug for CorsForbidden {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.debug_tuple("CorsForbidden").field(&self.kind).finish()
}
}

impl ::std::fmt::Display for CorsForbidden {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
let detail = match self.kind {
Forbidden::OriginNotAllowed => "origin not allowed",
Forbidden::MethodNotAllowed => "request-method not allowed",
Expand Down Expand Up @@ -572,7 +572,7 @@ mod internal {
<F::Error as CombineRejection<Rejection>>::One,
>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let pin = self.project();
match ready!(pin.inner.try_poll(cx)) {
Ok(inner) => {
Expand Down
16 changes: 8 additions & 8 deletions src/filters/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use self::internal::WithLog;
/// .map(warp::reply)
/// .with(log);
/// ```
pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
let func = move |info: Info| {
pub fn log(name: &'static str) -> Log<impl Fn(Info<'_>) + Copy> {
let func = move |info: Info<'_>| {
// TODO?
// - response content length?
log::info!(
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn log(name: &'static str) -> Log<impl Fn(Info) + Copy> {
/// ```
pub fn custom<F>(func: F) -> Log<F>
where
F: Fn(Info),
F: Fn(Info<'_>),
{
Log { func }
}
Expand All @@ -93,7 +93,7 @@ pub struct Info<'a> {

impl<FN, F> WrapSealed<F> for Log<FN>
where
FN: Fn(Info) + Clone + Send,
FN: Fn(Info<'_>) + Clone + Send,
F: Filter + Clone + Send,
F::Extract: Reply,
F::Error: IsReject,
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<'a> Info<'a> {
struct OptFmt<T>(Option<T>);

impl<T: fmt::Display> fmt::Display for OptFmt<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(ref t) = self.0 {
fmt::Display::fmt(t, f)
} else {
Expand Down Expand Up @@ -215,7 +215,7 @@ mod internal {

impl<FN, F> FilterBase for WithLog<FN, F>
where
FN: Fn(Info) + Clone + Send,
FN: Fn(Info<'_>) + Clone + Send,
F: Filter + Clone + Send,
F::Extract: Reply,
F::Error: IsReject,
Expand Down Expand Up @@ -245,14 +245,14 @@ mod internal {

impl<FN, F> Future for WithLogFuture<FN, F>
where
FN: Fn(Info),
FN: Fn(Info<'_>),
F: TryFuture,
F::Ok: Reply,
F::Error: IsReject,
{
type Output = Result<(Logged,), F::Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let pin = self.as_mut().project();
let (result, status) = match ready!(pin.future.try_poll(cx)) {
Ok(reply) => {
Expand Down
8 changes: 4 additions & 4 deletions src/filters/multipart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ impl FilterBase for FormOptions {
// ===== impl FormData =====

impl fmt::Debug for FormData {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FormData").finish()
}
}

impl Stream for FormData {
type Item = Result<Part, crate::Error>;

fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match (*self).inner.read_entry() {
Ok(Some(mut field)) => {
let mut data = Vec::new();
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Part {
}

impl fmt::Debug for Part {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut builder = f.debug_struct("Part");
builder.field("name", &self.name);

Expand All @@ -184,7 +184,7 @@ struct PartStream(Part);
impl Stream for PartStream {
type Item = Result<Bytes, crate::Error>;

fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> {
fn poll_next(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Poll::Ready(self.0.take_data())
}
}
6 changes: 3 additions & 3 deletions src/filters/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl Tail {
}

impl fmt::Debug for Tail {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}
}
Expand Down Expand Up @@ -376,7 +376,7 @@ impl Peek {
}

impl fmt::Debug for Peek {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}
}
Expand Down Expand Up @@ -427,7 +427,7 @@ impl FullPath {
}

impl fmt::Debug for FullPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}
}
Expand Down
Loading

0 comments on commit eba6477

Please sign in to comment.