Exclude usage of atomic types if not supported for the target
The gate is only added for Rust >= v1.60, since earlier versions don't support #[cfg(target_has_atomic = ...)]
This commit is contained in:
parent
2982681d59
commit
2961c0c589
|
@ -23,7 +23,7 @@ fn main() {
|
||||||
.parse::<u64>()
|
.parse::<u64>()
|
||||||
.expect("invalid Rust minor version");
|
.expect("invalid Rust minor version");
|
||||||
|
|
||||||
for activate_version in &[46, 53] {
|
for activate_version in &[46, 53, 60] {
|
||||||
if minor >= *activate_version {
|
if minor >= *activate_version {
|
||||||
println!("cargo:rustc-cfg=rust_v_1_{}", activate_version);
|
println!("cargo:rustc-cfg=rust_v_1_{}", activate_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
//! is minimal but we may extend it in the future if needed.
|
//! is minimal but we may extend it in the future if needed.
|
||||||
|
|
||||||
use alloc::rc::Rc;
|
use alloc::rc::Rc;
|
||||||
|
#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))]
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
|
@ -279,6 +280,9 @@ impl<'a> From<&'a Script> for Cow<'a, Script> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Note: This will fail to compile on old Rust for targets that don't support atomics
|
||||||
|
#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(target_has_atomic = "ptr")))]
|
||||||
impl<'a> From<&'a Script> for Arc<Script> {
|
impl<'a> From<&'a Script> for Arc<Script> {
|
||||||
fn from(value: &'a Script) -> Self {
|
fn from(value: &'a Script) -> Self {
|
||||||
let rw: *const [u8] = Arc::into_raw(Arc::from(&value.0));
|
let rw: *const [u8] = Arc::into_raw(Arc::from(&value.0));
|
||||||
|
|
|
@ -720,6 +720,9 @@ impl<T: Encodable> Encodable for rc::Rc<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Note: This will fail to compile on old Rust for targets that don't support atomics
|
||||||
|
#[cfg(any(not(rust_v_1_60), target_has_atomic = "ptr"))]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(target_has_atomic = "ptr")))]
|
||||||
impl<T: Encodable> Encodable for sync::Arc<T> {
|
impl<T: Encodable> Encodable for sync::Arc<T> {
|
||||||
fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
|
||||||
(**self).consensus_encode(w)
|
(**self).consensus_encode(w)
|
||||||
|
|
|
@ -160,7 +160,10 @@ mod io_extras {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
mod prelude {
|
mod prelude {
|
||||||
#[cfg(all(not(feature = "std"), not(test)))]
|
#[cfg(all(not(feature = "std"), not(test)))]
|
||||||
pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, Cow, ToOwned}, slice, rc, sync};
|
pub use alloc::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, Cow, ToOwned}, slice, rc};
|
||||||
|
|
||||||
|
#[cfg(all(not(feature = "std"), not(test), any(not(rust_v_1_60), target_has_atomic = "ptr")))]
|
||||||
|
pub use alloc::sync;
|
||||||
|
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, Cow, ToOwned}, slice, rc, sync};
|
pub use std::{string::{String, ToString}, vec::Vec, boxed::Box, borrow::{Borrow, Cow, ToOwned}, slice, rc, sync};
|
||||||
|
|
Loading…
Reference in New Issue