Skip to content

chore: use 2018 edition idioms #1910

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Aug 21, 2019
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
4 changes: 1 addition & 3 deletions examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![deny(warnings)]
extern crate hyper;
extern crate pretty_env_logger;

#![warn(rust_2018_idioms)]
use std::env;
use std::io::{self, Write};

Expand Down
5 changes: 2 additions & 3 deletions examples/client_json.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#![deny(warnings)]
extern crate hyper;
#![warn(rust_2018_idioms)]

#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;

use hyper::Client;
use futures_util::TryStreamExt;
Expand Down
3 changes: 1 addition & 2 deletions examples/multi_server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(warnings)]
extern crate hyper;
extern crate pretty_env_logger;
#![warn(rust_2018_idioms)]

use hyper::{Body, Request, Response, Server};
use hyper::service::{service_fn, make_service_fn};
Expand Down
4 changes: 1 addition & 3 deletions examples/params.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// #![deny(warnings)] // FIXME: https://github.com/rust-lang/rust/issues/62411
extern crate hyper;
extern crate pretty_env_logger;
extern crate url;
#![warn(rust_2018_idioms)]

use hyper::{Body, Method, Request, Response, Server, StatusCode};
use hyper::service::{service_fn, make_service_fn};
Expand Down
4 changes: 1 addition & 3 deletions src/body/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use futures_core::{Stream, TryStream};
use futures_channel::{mpsc, oneshot};
use futures_util::TryStreamExt;
//use tokio_buf::SizeHint;
use h2;
use http::HeaderMap;

use crate::common::{Future, Never, Pin, Poll, task};
Expand Down Expand Up @@ -130,7 +129,6 @@ impl Body {
///
/// ```
/// # use hyper::Body;
/// # use futures_util;
/// # fn main() {
/// let chunks: Vec<Result<_, ::std::io::Error>> = vec![
/// Ok("hello"),
Expand Down Expand Up @@ -346,7 +344,7 @@ impl Payload for Body {
}

impl fmt::Debug for Body {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[derive(Debug)]
struct Streaming;
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/body/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl AsRef<[u8]> for Chunk {

impl fmt::Debug for Chunk {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.bytes, f)
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/client/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use std::sync::Arc;

use bytes::Bytes;
use futures_util::future::{self, Either, FutureExt as _};
use h2;
use tokio_io::{AsyncRead, AsyncWrite};

use crate::body::Payload;
Expand Down Expand Up @@ -258,7 +257,7 @@ impl<T, B> Service for SendRequest<T, B> {
*/

impl<B> fmt::Debug for SendRequest<B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SendRequest")
.finish()
}
Expand Down Expand Up @@ -305,7 +304,7 @@ where
}

impl<B> fmt::Debug for Http2SendRequest<B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Http2SendRequest")
.finish()
}
Expand Down Expand Up @@ -410,7 +409,7 @@ where
T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static,
B: Payload + 'static,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Connection")
.finish()
}
Expand Down Expand Up @@ -575,7 +574,7 @@ impl Future for ResponseFuture {
}

impl fmt::Debug for ResponseFuture {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ResponseFuture")
.finish()
}
Expand Down
12 changes: 6 additions & 6 deletions src/client/connect/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ impl Name {
}

impl fmt::Debug for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.host, f)
}
}

impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.host, f)
}
}
Expand All @@ -100,7 +100,7 @@ impl FromStr for Name {
pub struct InvalidNameError(());

impl fmt::Display for InvalidNameError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Not a valid domain name")
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ impl Resolve for GaiResolver {
}

impl fmt::Debug for GaiResolver {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("GaiResolver")
}
}
Expand All @@ -184,7 +184,7 @@ impl Future for GaiFuture {
}

impl fmt::Debug for GaiFuture {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("GaiFuture")
}
}
Expand All @@ -198,7 +198,7 @@ impl Iterator for GaiAddrs {
}

impl fmt::Debug for GaiAddrs {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("GaiAddrs")
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<R> HttpConnector<R> {

// R: Debug required for now to allow adding it to debug output later...
impl<R: fmt::Debug> fmt::Debug for HttpConnector<R> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("HttpConnector")
.finish()
}
Expand Down Expand Up @@ -282,7 +282,7 @@ enum InvalidUrl {
}

impl fmt::Display for InvalidUrl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.description())
}
}
Expand Down Expand Up @@ -382,7 +382,7 @@ where
}

impl<R: Resolve + fmt::Debug> fmt::Debug for HttpConnecting<R> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("HttpConnecting")
}
}
Expand Down Expand Up @@ -615,8 +615,6 @@ mod tests {
#[test]
#[cfg_attr(not(feature = "__internal_happy_eyeballs_tests"), ignore)]
fn client_happy_eyeballs() {
extern crate pretty_env_logger;

use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, TcpListener};
use std::time::{Duration, Instant};

Expand Down
2 changes: 1 addition & 1 deletion src/client/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl Clone for Extra {
}

impl fmt::Debug for Extra {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Extra")
.finish()
}
Expand Down
2 changes: 0 additions & 2 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use futures_core::Stream;
use futures_channel::{mpsc, oneshot};
use futures_util::future;
use want;

use crate::common::{Future, Never, Pin, Poll, task};

Expand Down Expand Up @@ -254,7 +253,6 @@ mod tests {
// trigger a warning to remind us
use crate::Error;
/*
extern crate pretty_env_logger;
#[cfg(feature = "nightly")]
extern crate test;

Expand Down
11 changes: 3 additions & 8 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ impl Client<(), Body> {
/// # Example
///
/// ```
/// # extern crate hyper;
/// # #[cfg(feature = "runtime")]
/// # fn run () {
/// use hyper::Client;
Expand Down Expand Up @@ -175,7 +174,6 @@ where C: Connect + Sync + 'static,
/// # Example
///
/// ```
/// # extern crate hyper;
/// # #[cfg(feature = "runtime")]
/// # fn run () {
/// use hyper::{Client, Uri};
Expand Down Expand Up @@ -205,7 +203,6 @@ where C: Connect + Sync + 'static,
/// # Example
///
/// ```
/// # extern crate hyper;
/// # #[cfg(feature = "runtime")]
/// # fn run () {
/// use hyper::{Body, Client, Request};
Expand Down Expand Up @@ -558,7 +555,7 @@ impl<C, B> Clone for Client<C, B> {
}

impl<C, B> fmt::Debug for Client<C, B> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Client")
.finish()
}
Expand All @@ -580,7 +577,7 @@ impl ResponseFuture {
}

impl fmt::Debug for ResponseFuture {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("Future<Response>")
}
}
Expand Down Expand Up @@ -821,7 +818,6 @@ fn set_scheme(uri: &mut Uri, scheme: Scheme) {
/// # Example
///
/// ```
/// # extern crate hyper;
/// # #[cfg(feature = "runtime")]
/// # fn run () {
/// use hyper::Client;
Expand Down Expand Up @@ -1053,7 +1049,7 @@ impl Builder {
}

impl fmt::Debug for Builder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Builder")
.field("client_config", &self.client_config)
.field("conn_builder", &self.conn_builder)
Expand Down Expand Up @@ -1097,7 +1093,6 @@ mod unit_tests {

#[test]
fn test_authority_form() {
extern crate pretty_env_logger;
let _ = pretty_env_logger::try_init();

let mut uri = "http://hyper.rs".parse().unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<T: Poolable> Pool<T> {
}

#[cfg(test)]
fn locked(&self) -> ::std::sync::MutexGuard<PoolInner<T>> {
fn locked(&self) -> ::std::sync::MutexGuard<'_, PoolInner<T>> {
self
.inner
.as_ref()
Expand Down Expand Up @@ -263,7 +263,7 @@ impl<T: Poolable> Pool<T> {
}

/// Pop off this list, looking for a usable connection that hasn't expired.
struct IdlePopper<'a, T: 'a> {
struct IdlePopper<'a, T> {
key: &'a Key,
list: &'a mut Vec<Idle<T>>,
}
Expand Down Expand Up @@ -547,7 +547,7 @@ impl<T: Poolable> Drop for Pooled<T> {
}

impl<T: Poolable> fmt::Debug for Pooled<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Pooled")
.field("key", &self.key)
.finish()
Expand Down
1 change: 0 additions & 1 deletion src/client/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use super::Client;
/*
#![cfg(feature = "runtime")]
extern crate pretty_env_logger;

use futures::{Async, Future, Stream};
use futures::future::poll_fn;
Expand Down
6 changes: 3 additions & 3 deletions src/common/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ impl Exec {
struct TokioSpawnError;

impl fmt::Debug for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}

impl fmt::Display for TokioSpawnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
}
}
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Exec {
}

impl fmt::Debug for Exec {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Exec")
.finish()
}
Expand Down
3 changes: 1 addition & 2 deletions src/common/io/rewind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ mod tests {
use super::Rewind;
/*
use super::*;
extern crate tokio_mockstream;
use self::tokio_mockstream::MockStream;
use tokio_mockstream::MockStream;
use std::io::Cursor;

// Test a partial rewind
Expand Down
2 changes: 1 addition & 1 deletion src/common/never.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt;
pub enum Never {}

impl fmt::Display for Never {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::Never;
/// A function to help "yield" a future, such that it is re-scheduled immediately.
///
/// Useful for spin counts, so a future doesn't hog too much time.
pub(crate) fn yield_now(cx: &mut Context) -> Poll<Never> {
pub(crate) fn yield_now(cx: &mut Context<'_>) -> Poll<Never> {
cx.waker().wake_by_ref();
Poll::Pending
}
Loading