about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-07-31 19:27:20 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-07-31 19:27:20 +0200
commitd31f3605cea39530cb6b5b1c89934b174c886f49 (patch)
tree87bb8069eaa44b046837e0f6782996a1ff840cde
parentec3586eab943d7c6c83d211f629a691fc8c14603 (diff)
downloadrust-d31f3605cea39530cb6b5b1c89934b174c886f49.tar.gz
rust-d31f3605cea39530cb6b5b1c89934b174c886f49.zip
Properly cfg the `max` field of Limit
-rw-r--r--crates/limit/src/lib.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/limit/src/lib.rs b/crates/limit/src/lib.rs
index 3c1da80edb9..d6a706a7cd7 100644
--- a/crates/limit/src/lib.rs
+++ b/crates/limit/src/lib.rs
@@ -2,12 +2,13 @@
 
 #![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
 
+#[cfg(feature = "tracking")]
 use std::sync::atomic::AtomicUsize;
 
 /// Represents a struct used to enforce a numerical limit.
 pub struct Limit {
     upper_bound: usize,
-    #[allow(unused)]
+    #[cfg(feature = "tracking")]
     max: AtomicUsize,
 }
 
@@ -15,14 +16,22 @@ impl Limit {
     /// Creates a new limit.
     #[inline]
     pub const fn new(upper_bound: usize) -> Self {
-        Self { upper_bound, max: AtomicUsize::new(0) }
+        Self {
+            upper_bound,
+            #[cfg(feature = "tracking")]
+            max: AtomicUsize::new(0),
+        }
     }
 
     /// Creates a new limit.
     #[inline]
     #[cfg(feature = "tracking")]
     pub const fn new_tracking(upper_bound: usize) -> Self {
-        Self { upper_bound, max: AtomicUsize::new(1) }
+        Self {
+            upper_bound,
+            #[cfg(feature = "tracking")]
+            max: AtomicUsize::new(1),
+        }
     }
 
     /// Gets the underlying numeric limit.