Skip to content

Commit 890f66a

Browse files
fix gate-ing of atomic64 in tests (#607)
* fix gate-ing of atomic64 in tests * switch AtomicU64 -> AtomicUsize and remove the cfg target_has_atomic stuff
1 parent 578c2b2 commit 890f66a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

tower-http/src/request_id.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! };
1111
//! use http_body_util::Full;
1212
//! use bytes::Bytes;
13-
//! use std::sync::{Arc, atomic::{AtomicU64, Ordering}};
13+
//! use std::sync::{Arc, atomic::{AtomicUsize, Ordering}};
1414
//!
1515
//! # #[tokio::main]
1616
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -21,7 +21,7 @@
2121
//! // A `MakeRequestId` that increments an atomic counter
2222
//! #[derive(Clone, Default)]
2323
//! struct MyMakeRequestId {
24-
//! counter: Arc<AtomicU64>,
24+
//! counter: Arc<AtomicUsize>,
2525
//! }
2626
//!
2727
//! impl MakeRequestId for MyMakeRequestId {
@@ -68,15 +68,15 @@
6868
//! # };
6969
//! # use bytes::Bytes;
7070
//! # use http_body_util::Full;
71-
//! # use std::sync::{Arc, atomic::{AtomicU64, Ordering}};
71+
//! # use std::sync::{Arc, atomic::{AtomicUsize, Ordering}};
7272
//! # #[tokio::main]
7373
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
7474
//! # let handler = tower::service_fn(|request: Request<Full<Bytes>>| async move {
7575
//! # Ok::<_, std::convert::Infallible>(Response::new(request.into_body()))
7676
//! # });
7777
//! # #[derive(Clone, Default)]
7878
//! # struct MyMakeRequestId {
79-
//! # counter: Arc<AtomicU64>,
79+
//! # counter: Arc<AtomicUsize>,
8080
//! # }
8181
//! # impl MakeRequestId for MyMakeRequestId {
8282
//! # fn make_request_id<B>(&mut self, request: &Request<B>) -> Option<RequestId> {
@@ -122,15 +122,15 @@
122122
//! # };
123123
//! # use http_body_util::Full;
124124
//! # use bytes::Bytes;
125-
//! # use std::sync::{Arc, atomic::{AtomicU64, Ordering}};
125+
//! # use std::sync::{Arc, atomic::{AtomicUsize, Ordering}};
126126
//! # #[tokio::main]
127127
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
128128
//! # let handler = tower::service_fn(|request: Request<Full<Bytes>>| async move {
129129
//! # Ok::<_, std::convert::Infallible>(Response::new(request.into_body()))
130130
//! # });
131131
//! # #[derive(Clone, Default)]
132132
//! # struct MyMakeRequestId {
133-
//! # counter: Arc<AtomicU64>,
133+
//! # counter: Arc<AtomicUsize>,
134134
//! # }
135135
//! # impl MakeRequestId for MyMakeRequestId {
136136
//! # fn make_request_id<B>(&mut self, request: &Request<B>) -> Option<RequestId> {
@@ -483,12 +483,10 @@ mod tests {
483483
use crate::test_helpers::Body;
484484
use crate::ServiceBuilderExt as _;
485485
use http::Response;
486+
use std::sync::atomic::AtomicUsize;
486487
use std::{
487488
convert::Infallible,
488-
sync::{
489-
atomic::{AtomicU64, Ordering},
490-
Arc,
491-
},
489+
sync::{atomic::Ordering, Arc},
492490
};
493491
use tower::{ServiceBuilder, ServiceExt};
494492

@@ -574,7 +572,7 @@ mod tests {
574572
}
575573

576574
#[derive(Clone, Default)]
577-
struct Counter(Arc<AtomicU64>);
575+
struct Counter(Arc<AtomicUsize>);
578576

579577
impl MakeRequestId for Counter {
580578
fn make_request_id<B>(&mut self, _request: &Request<B>) -> Option<RequestId> {

0 commit comments

Comments
 (0)