Skip to content

Commit 215d548

Browse files
committed
chore: use 2018 edition idioms
1 parent 778701a commit 215d548

38 files changed

+88
-122
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl Payload for Body {
346346
}
347347

348348
impl fmt::Debug for Body {
349-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
349+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
350350
#[derive(Debug)]
351351
struct Streaming;
352352
#[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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<T, B> Service for SendRequest<T, B> {
258258
*/
259259

260260
impl<B> fmt::Debug for SendRequest<B> {
261-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
261+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
262262
f.debug_struct("SendRequest")
263263
.finish()
264264
}
@@ -305,7 +305,7 @@ where
305305
}
306306

307307
impl<B> fmt::Debug for Http2SendRequest<B> {
308-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
308+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
309309
f.debug_struct("Http2SendRequest")
310310
.finish()
311311
}
@@ -410,7 +410,7 @@ where
410410
T: AsyncRead + AsyncWrite + fmt::Debug + Send + 'static,
411411
B: Payload + 'static,
412412
{
413-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
413+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
414414
f.debug_struct("Connection")
415415
.finish()
416416
}
@@ -575,7 +575,7 @@ impl Future for ResponseFuture {
575575
}
576576

577577
impl fmt::Debug for ResponseFuture {
578-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
578+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
579579
f.debug_struct("ResponseFuture")
580580
.finish()
581581
}

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ mod tests {
254254
// trigger a warning to remind us
255255
use crate::Error;
256256
/*
257-
extern crate pretty_env_logger;
258257
#[cfg(feature = "nightly")]
259258
extern crate test;
260259

src/client/mod.rs

Lines changed: 4 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,7 @@ mod unit_tests {
10971093

10981094
#[test]
10991095
fn test_authority_form() {
1100-
extern crate pretty_env_logger;
1096+
use pretty_env_logger;
11011097
let _ = pretty_env_logger::try_init();
11021098

11031099
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
}

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl Error {
284284
}
285285

286286
impl fmt::Debug for Error {
287-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
287+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
288288
let mut f = f.debug_tuple("Error");
289289
f.field(&self.inner.kind);
290290
if let Some(ref cause) = self.inner.cause {
@@ -295,7 +295,7 @@ impl fmt::Debug for Error {
295295
}
296296

297297
impl fmt::Display for Error {
298-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
298+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
299299
if let Some(ref cause) = self.inner.cause {
300300
write!(f, "{}: {}", self.description(), cause)
301301
} else {

src/headers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn content_length_parse_all(headers: &HeaderMap) -> Option<u64> {
3333
content_length_parse_all_values(headers.get_all(CONTENT_LENGTH).into_iter())
3434
}
3535

36-
pub fn content_length_parse_all_values(values: ValueIter<HeaderValue>) -> Option<u64> {
36+
pub fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>) -> Option<u64> {
3737
// If multiple Content-Length headers were sent, everything can still
3838
// be alright if they all contain the same value, and all parse
3939
// correctly. If not, then it's an error.
@@ -74,7 +74,7 @@ pub fn transfer_encoding_is_chunked(headers: &HeaderMap) -> bool {
7474
is_chunked(headers.get_all(TRANSFER_ENCODING).into_iter())
7575
}
7676

77-
pub fn is_chunked(mut encodings: ValueIter<HeaderValue>) -> bool {
77+
pub fn is_chunked(mut encodings: ValueIter<'_, HeaderValue>) -> bool {
7878
// chunked must always be the last encoding, according to spec
7979
if let Some(line) = encodings.next_back() {
8080
return is_chunked_(line);
@@ -94,7 +94,7 @@ pub fn is_chunked_(value: &HeaderValue) -> bool {
9494
false
9595
}
9696

97-
pub fn add_chunked(mut entry: OccupiedEntry<HeaderValue>) {
97+
pub fn add_chunked(mut entry: OccupiedEntry<'_, HeaderValue>) {
9898
const CHUNKED: &'static str = "chunked";
9999

100100
if let Some(line) = entry.iter_mut().next_back() {

0 commit comments

Comments
 (0)