11mod test_utils;
22
3+ use std:: future:: Future ;
34use std:: io:: { Read , Write } ;
45use std:: net:: { SocketAddr , TcpListener } ;
5- use std:: pin:: Pin ;
6+ use std:: pin:: { pin , Pin } ;
67use std:: sync:: atomic:: Ordering ;
78use std:: sync:: Arc ;
89use std:: task:: Poll ;
910use std:: thread;
1011use std:: time:: Duration ;
1112
1213use futures_channel:: { mpsc, oneshot} ;
14+ use futures_core:: Stream ;
1315use futures_util:: future:: { self , FutureExt , TryFutureExt } ;
1416use futures_util:: stream:: StreamExt ;
15- use futures_util:: { self , Stream } ;
1617use http_body_util:: BodyExt ;
1718use http_body_util:: { Empty , Full , StreamBody } ;
1819use tokio:: io:: { AsyncReadExt , AsyncWriteExt } ;
@@ -132,7 +133,7 @@ async fn drop_client_closes_idle_connections() {
132133 res. unwrap ( ) ;
133134
134135 // not closed yet, just idle
135- future:: poll_fn ( |ctx| {
136+ std :: future:: poll_fn ( |ctx| {
136137 assert ! ( Pin :: new( & mut closes) . poll_next( ctx) . is_pending( ) ) ;
137138 Poll :: Ready ( ( ) )
138139 } )
@@ -142,8 +143,7 @@ async fn drop_client_closes_idle_connections() {
142143 drop ( client) ;
143144
144145 // and wait a few ticks for the connections to close
145- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
146- futures_util:: pin_mut!( t) ;
146+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
147147 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
148148 future:: select ( t, close) . await ;
149149 t1. await . unwrap ( ) ;
@@ -192,8 +192,7 @@ async fn drop_response_future_closes_in_progress_connection() {
192192 future:: select ( res, rx1) . await ;
193193
194194 // res now dropped
195- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
196- futures_util:: pin_mut!( t) ;
195+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
197196 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
198197 future:: select ( t, close) . await ;
199198}
@@ -248,8 +247,7 @@ async fn drop_response_body_closes_in_progress_connection() {
248247 res. unwrap ( ) ;
249248
250249 // and wait a few ticks to see the connection drop
251- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
252- futures_util:: pin_mut!( t) ;
250+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
253251 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
254252 future:: select ( t, close) . await ;
255253}
@@ -301,8 +299,7 @@ async fn no_keep_alive_closes_connection() {
301299 let ( res, _) = future:: join ( res, rx) . await ;
302300 res. unwrap ( ) ;
303301
304- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
305- futures_util:: pin_mut!( t) ;
302+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
306303 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
307304 future:: select ( close, t) . await ;
308305}
@@ -348,8 +345,7 @@ async fn socket_disconnect_closes_idle_conn() {
348345 let ( res, _) = future:: join ( res, rx) . await ;
349346 res. unwrap ( ) ;
350347
351- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
352- futures_util:: pin_mut!( t) ;
348+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
353349 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
354350 future:: select ( t, close) . await ;
355351}
@@ -562,7 +558,7 @@ async fn client_keep_alive_when_response_before_request_body_ends() {
562558 } ) ;
563559
564560 future:: join ( res, rx2) . await . 0 . unwrap ( ) ;
565- future:: poll_fn ( |ctx| {
561+ std :: future:: poll_fn ( |ctx| {
566562 assert ! ( Pin :: new( & mut closes) . poll_next( ctx) . is_pending( ) ) ;
567563 Poll :: Ready ( ( ) )
568564 } )
@@ -571,8 +567,7 @@ async fn client_keep_alive_when_response_before_request_body_ends() {
571567 assert_eq ! ( connects. load( Ordering :: Relaxed ) , 1 ) ;
572568
573569 drop ( client) ;
574- let t = tokio:: time:: sleep ( Duration :: from_millis ( 100 ) ) . map ( |_| panic ! ( "time out" ) ) ;
575- futures_util:: pin_mut!( t) ;
570+ let t = pin ! ( tokio:: time:: sleep( Duration :: from_millis( 100 ) ) . map( |_| panic!( "time out" ) ) ) ;
576571 let close = closes. into_future ( ) . map ( |( opt, _) | opt. expect ( "closes" ) ) ;
577572 future:: select ( t, close) . await ;
578573}
@@ -1255,10 +1250,7 @@ impl tower_service::Service<hyper::Uri> for MockConnector {
12551250 type Response = crate :: MockConnection ;
12561251 type Error = std:: io:: Error ;
12571252 type Future = std:: pin:: Pin <
1258- Box <
1259- dyn futures_util:: Future < Output = std:: result:: Result < Self :: Response , Self :: Error > >
1260- + Send ,
1261- > ,
1253+ Box < dyn Future < Output = std:: result:: Result < Self :: Response , Self :: Error > > + Send > ,
12621254 > ;
12631255
12641256 // Polls the connector to check if it’s ready to handle a request.
0 commit comments