diff --git a/serde/build.rs b/serde/build.rs index 28321278d..391c5a2ef 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -33,6 +33,12 @@ fn main() { Err(_) => return, }; + // CString::into_boxed_c_str stabilized in Rust 1.20: + // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str + if minor >= 20 { + println!("cargo:rustc-cfg=de_boxed_c_str"); + } + // 128-bit integers stabilized in Rust 1.26: // https://blog.rust-lang.org/2018/05/10/Rust-1.26.html if minor >= 26 { diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index fdade5b39..6d3258832 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -573,7 +573,7 @@ macro_rules! forwarded_impl { } } -#[cfg(all(feature = "std", feature = "unstable"))] +#[cfg(all(feature = "std", de_boxed_c_str))] forwarded_impl!((), Box, CString::into_boxed_c_str); ////////////////////////////////////////////////////////////////////////////////