mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 15:31:07 +00:00
Invert build.rs cfgs in serde_derive
This commit is contained in:
@@ -13,14 +13,14 @@ fn main() {
|
|||||||
|
|
||||||
// Underscore const names stabilized in Rust 1.37:
|
// Underscore const names stabilized in Rust 1.37:
|
||||||
// https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#using-unnamed-const-items-for-macros
|
// https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#using-unnamed-const-items-for-macros
|
||||||
if minor >= 37 {
|
if minor < 37 {
|
||||||
println!("cargo:rustc-cfg=underscore_consts");
|
println!("cargo:rustc-cfg=no_underscore_consts");
|
||||||
}
|
}
|
||||||
|
|
||||||
// The ptr::addr_of! macro stabilized in Rust 1.51:
|
// The ptr::addr_of! macro stabilized in Rust 1.51:
|
||||||
// https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#stabilized-apis
|
// https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#stabilized-apis
|
||||||
if minor >= 51 {
|
if minor < 51 {
|
||||||
println!("cargo:rustc-cfg=ptr_addr_of");
|
println!("cargo:rustc-cfg=no_ptr_addr_of");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ pub fn wrap_in_const(
|
|||||||
) -> TokenStream {
|
) -> TokenStream {
|
||||||
let try_replacement = try::replacement();
|
let try_replacement = try::replacement();
|
||||||
|
|
||||||
let dummy_const = if cfg!(underscore_consts) {
|
let dummy_const = if cfg!(no_underscore_consts) {
|
||||||
format_ident!("_")
|
|
||||||
} else {
|
|
||||||
format_ident!("_IMPL_{}_FOR_{}", trait_, unraw(ty))
|
format_ident!("_IMPL_{}_FOR_{}", trait_, unraw(ty))
|
||||||
|
} else {
|
||||||
|
format_ident!("_")
|
||||||
};
|
};
|
||||||
|
|
||||||
let use_serde = match serde_path {
|
let use_serde = match serde_path {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field]) -> Toke
|
|||||||
|
|
||||||
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
|
let members = fields.iter().map(|field| &field.member).collect::<Vec<_>>();
|
||||||
|
|
||||||
#[cfg(ptr_addr_of)]
|
#[cfg(not(no_ptr_addr_of))]
|
||||||
{
|
{
|
||||||
quote! {
|
quote! {
|
||||||
match _serde::__private::None::<&#type_ident #ty_generics> {
|
match _serde::__private::None::<&#type_ident #ty_generics> {
|
||||||
@@ -111,7 +111,7 @@ fn pretend_fields_used_struct_packed(cont: &Container, fields: &[Field]) -> Toke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(ptr_addr_of))]
|
#[cfg(no_ptr_addr_of)]
|
||||||
{
|
{
|
||||||
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user