From a2db8f9283a11bef18aec38772155eb6e7407ca0 Mon Sep 17 00:00:00 2001
From: Joe Richey <joerichey@google.com>
Date: Wed, 3 Apr 2024 22:29:33 -0700
Subject: [PATCH] Gate atomics behind Rust 1.60

Signed-off-by: Joe Richey <joerichey@google.com>
---
 Cargo.toml | 4 ++++
 src/lib.rs | 1 +
 2 files changed, 5 insertions(+)

diff --git a/Cargo.toml b/Cargo.toml
index 09a2ebbe464..ee3f7b83b29 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,6 +35,10 @@ exclude = [".*"]
 # From 1.61.0, Rust supports generic types with trait bounds in `const fn`.
 zerocopy-generic-bounds-in-const-fn = "1.61.0"
 
+# From 1.60.0, Rust supports detecting if a target supports atomics, so we can
+# reliably implement traits on the Atomic* types.
+zerocopy-atomics = "1.60.0"
+
 # When the "simd" feature is enabled, include SIMD types from the
 # `core::arch::aarch64` module, which was stabilized in 1.59.0. On earlier Rust
 # versions, these types require the "simd-nightly" feature.
diff --git a/src/lib.rs b/src/lib.rs
index 0c54540c93f..4f8394765d2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -278,6 +278,7 @@ extern crate self as zerocopy;
 #[macro_use]
 mod macros;
 
+#[cfg(zerocopy_atomics)]
 mod atomics;
 pub mod byteorder;
 mod deprecated;