Skip to content

Commit fc7f81b

Browse files
tesujiseanmonstar
authored andcommitted
style(lib): use rust 2018 edition idioms (#1910)
1 parent ae75b3a commit fc7f81b

38 files changed

+90
-146
lines changed

examples/client.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![deny(warnings)]
2-
extern crate hyper;
3-
extern crate pretty_env_logger;
4-
2+
#![warn(rust_2018_idioms)]
53
use std::env;
64
use std::io::{self, Write};
75

examples/client_json.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#![deny(warnings)]
2-
extern crate hyper;
2+
#![warn(rust_2018_idioms)]
3+
34
#[macro_use]
45
extern crate serde_derive;
5-
extern crate serde;
6-
extern crate serde_json;
76

87
use hyper::Client;
98
use futures_util::TryStreamExt;

examples/multi_server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![deny(warnings)]
2-
extern crate hyper;
3-
extern crate pretty_env_logger;
2+
#![warn(rust_2018_idioms)]
43

54
use hyper::{Body, Request, Response, Server};
65
use hyper::service::{service_fn, make_service_fn};

examples/params.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// #![deny(warnings)] // FIXME: https://github.com/rust-lang/rust/issues/62411
2-
extern crate hyper;
3-
extern crate pretty_env_logger;
4-
extern crate url;
2+
#![warn(rust_2018_idioms)]
53

64
use hyper::{Body, Method, Request, Response, Server, StatusCode};
75
use hyper::service::{service_fn, make_service_fn};

src/body/body.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use futures_core::{Stream, TryStream};
77
use futures_channel::{mpsc, oneshot};
88
use futures_util::TryStreamExt;
99
//use tokio_buf::SizeHint;
10-
use h2;
1110
use http::HeaderMap;
1211

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

348346
impl fmt::Debug for Body {
349-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
347+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
350348
#[derive(Debug)]
351349
struct Streaming;
352350
#[derive(Debug)]

src/body/chunk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl AsRef<[u8]> for Chunk {
113113

114114
impl fmt::Debug for Chunk {
115115
#[inline]
116-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
116+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
117117
fmt::Debug::fmt(&self.bytes, f)
118118
}
119119
}

src/client/conn.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use std::sync::Arc;
1414

1515
use bytes::Bytes;
1616
use futures_util::future::{self, Either, FutureExt as _};
17-
use h2;
1817
use tokio_io::{AsyncRead, AsyncWrite};
1918

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

260259
impl<B> fmt::Debug for SendRequest<B> {
261-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
260+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
262261
f.debug_struct("SendRequest")
263262
.finish()
264263
}
@@ -305,7 +304,7 @@ where
305304
}
306305

307306
impl<B> fmt::Debug for Http2SendRequest<B> {
308-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
307+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
309308
f.debug_struct("Http2SendRequest")
310309
.finish()
311310
}
@@ -410,7 +409,7 @@ where
410409
T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static,
411410
B: Payload + 'static,
412411
{
413-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
412+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
414413
f.debug_struct("Connection")
415414
.finish()
416415
}
@@ -575,7 +574,7 @@ impl Future for ResponseFuture {
575574
}
576575

577576
impl fmt::Debug for ResponseFuture {
578-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
577+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
579578
f.debug_struct("ResponseFuture")
580579
.finish()
581580
}

src/client/connect/dns.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ impl Name {
7575
}
7676

7777
impl fmt::Debug for Name {
78-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7979
fmt::Debug::fmt(&self.host, f)
8080
}
8181
}
8282

8383
impl fmt::Display for Name {
84-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
84+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8585
fmt::Display::fmt(&self.host, f)
8686
}
8787
}
@@ -100,7 +100,7 @@ impl FromStr for Name {
100100
pub struct InvalidNameError(());
101101

102102
impl fmt::Display for InvalidNameError {
103-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104104
f.write_str("Not a valid domain name")
105105
}
106106
}
@@ -166,7 +166,7 @@ impl Resolve for GaiResolver {
166166
}
167167

168168
impl fmt::Debug for GaiResolver {
169-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
170170
f.pad("GaiResolver")
171171
}
172172
}
@@ -184,7 +184,7 @@ impl Future for GaiFuture {
184184
}
185185

186186
impl fmt::Debug for GaiFuture {
187-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
187+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
188188
f.pad("GaiFuture")
189189
}
190190
}
@@ -198,7 +198,7 @@ impl Iterator for GaiAddrs {
198198
}
199199

200200
impl fmt::Debug for GaiAddrs {
201-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
201+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202202
f.pad("GaiAddrs")
203203
}
204204
}

src/client/connect/http.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<R> HttpConnector<R> {
198198

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

284284
impl fmt::Display for InvalidUrl {
285-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
285+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
286286
f.write_str(self.description())
287287
}
288288
}
@@ -382,7 +382,7 @@ where
382382
}
383383

384384
impl<R: Resolve + fmt::Debug> fmt::Debug for HttpConnecting<R> {
385-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
385+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
386386
f.pad("HttpConnecting")
387387
}
388388
}
@@ -615,8 +615,6 @@ mod tests {
615615
#[test]
616616
#[cfg_attr(not(feature = "__internal_happy_eyeballs_tests"), ignore)]
617617
fn client_happy_eyeballs() {
618-
extern crate pretty_env_logger;
619-
620618
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, TcpListener};
621619
use std::time::{Duration, Instant};
622620

src/client/connect/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl Clone for Extra {
346346
}
347347

348348
impl fmt::Debug for Extra {
349-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
349+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
350350
f.debug_struct("Extra")
351351
.finish()
352352
}

src/client/dispatch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use futures_core::Stream;
22
use futures_channel::{mpsc, oneshot};
33
use futures_util::future;
4-
use want;
54

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

@@ -254,7 +253,6 @@ mod tests {
254253
// trigger a warning to remind us
255254
use crate::Error;
256255
/*
257-
extern crate pretty_env_logger;
258256
#[cfg(feature = "nightly")]
259257
extern crate test;
260258

src/client/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ impl Client<(), Body> {
137137
/// # Example
138138
///
139139
/// ```
140-
/// # extern crate hyper;
141140
/// # #[cfg(feature = "runtime")]
142141
/// # fn run () {
143142
/// use hyper::Client;
@@ -175,7 +174,6 @@ where C: Connect + Sync + 'static,
175174
/// # Example
176175
///
177176
/// ```
178-
/// # extern crate hyper;
179177
/// # #[cfg(feature = "runtime")]
180178
/// # fn run () {
181179
/// use hyper::{Client, Uri};
@@ -205,7 +203,6 @@ where C: Connect + Sync + 'static,
205203
/// # Example
206204
///
207205
/// ```
208-
/// # extern crate hyper;
209206
/// # #[cfg(feature = "runtime")]
210207
/// # fn run () {
211208
/// use hyper::{Body, Client, Request};
@@ -558,7 +555,7 @@ impl<C, B> Clone for Client<C, B> {
558555
}
559556

560557
impl<C, B> fmt::Debug for Client<C, B> {
561-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
558+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
562559
f.debug_struct("Client")
563560
.finish()
564561
}
@@ -580,7 +577,7 @@ impl ResponseFuture {
580577
}
581578

582579
impl fmt::Debug for ResponseFuture {
583-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
580+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
584581
f.pad("Future<Response>")
585582
}
586583
}
@@ -821,7 +818,6 @@ fn set_scheme(uri: &mut Uri, scheme: Scheme) {
821818
/// # Example
822819
///
823820
/// ```
824-
/// # extern crate hyper;
825821
/// # #[cfg(feature = "runtime")]
826822
/// # fn run () {
827823
/// use hyper::Client;
@@ -1053,7 +1049,7 @@ impl Builder {
10531049
}
10541050

10551051
impl fmt::Debug for Builder {
1056-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1052+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10571053
f.debug_struct("Builder")
10581054
.field("client_config", &self.client_config)
10591055
.field("conn_builder", &self.conn_builder)
@@ -1097,7 +1093,6 @@ mod unit_tests {
10971093

10981094
#[test]
10991095
fn test_authority_form() {
1100-
extern crate pretty_env_logger;
11011096
let _ = pretty_env_logger::try_init();
11021097

11031098
let mut uri = "http://hyper.rs".parse().unwrap();

src/client/pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<T: Poolable> Pool<T> {
171171
}
172172

173173
#[cfg(test)]
174-
fn locked(&self) -> ::std::sync::MutexGuard<PoolInner<T>> {
174+
fn locked(&self) -> ::std::sync::MutexGuard<'_, PoolInner<T>> {
175175
self
176176
.inner
177177
.as_ref()
@@ -263,7 +263,7 @@ impl<T: Poolable> Pool<T> {
263263
}
264264

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

549549
impl<T: Poolable> fmt::Debug for Pooled<T> {
550-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
550+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
551551
f.debug_struct("Pooled")
552552
.field("key", &self.key)
553553
.finish()

src/client/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use super::Client;
44
/*
55
#![cfg(feature = "runtime")]
6-
extern crate pretty_env_logger;
76
87
use futures::{Async, Future, Stream};
98
use futures::future::poll_fn;

src/common/exec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ impl Exec {
5757
struct TokioSpawnError;
5858

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

6565
impl fmt::Display for TokioSpawnError {
66-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6767
fmt::Display::fmt("tokio::spawn failed (is a tokio runtime running this future?)", f)
6868
}
6969
}
@@ -99,7 +99,7 @@ impl Exec {
9999
}
100100

101101
impl fmt::Debug for Exec {
102-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
102+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
103103
f.debug_struct("Exec")
104104
.finish()
105105
}

src/common/io/rewind.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ mod tests {
129129
use super::Rewind;
130130
/*
131131
use super::*;
132-
extern crate tokio_mockstream;
133-
use self::tokio_mockstream::MockStream;
132+
use tokio_mockstream::MockStream;
134133
use std::io::Cursor;
135134
136135
// Test a partial rewind

src/common/never.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fmt;
99
pub enum Never {}
1010

1111
impl fmt::Display for Never {
12-
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
12+
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
1313
match *self {}
1414
}
1515
}

src/common/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::Never;
44
/// A function to help "yield" a future, such that it is re-scheduled immediately.
55
///
66
/// Useful for spin counts, so a future doesn't hog too much time.
7-
pub(crate) fn yield_now(cx: &mut Context) -> Poll<Never> {
7+
pub(crate) fn yield_now(cx: &mut Context<'_>) -> Poll<Never> {
88
cx.waker().wake_by_ref();
99
Poll::Pending
1010
}

0 commit comments

Comments
 (0)