aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-10 15:42:20 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-10 15:42:20 +0000
commit7cc3cc304b09494c5191e02162eadfbfb93bd675 (patch)
treead34adc71d5d004fa5429d91527ab336c659986f
parenta23e1b9148efc7b197b48b6aba9e37406806c284 (diff)
parent07602038510ecb113bfe9b29516405b5ff31a9d4 (diff)
downloadserde-busytown-mac-infra-release.tar.gz
Snap for 11819167 from 07602038510ecb113bfe9b29516405b5ff31a9d4 to busytown-mac-infra-releasebusytown-mac-infra-release
Change-Id: I8778fb296f131898b435c74b15b7006f85bb8e39
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp36
-rw-r--r--Cargo.toml13
-rw-r--r--Cargo.toml.orig7
-rw-r--r--LICENSE-APACHE25
-rw-r--r--METADATA8
-rw-r--r--README.md10
-rw-r--r--build.rs16
-rw-r--r--cargo2android.json15
-rw-r--r--cargo2rulesmk.json4
-rw-r--r--cargo_embargo.json34
-rw-r--r--patches/rules.mk.diff30
-rw-r--r--rules.mk37
-rw-r--r--src/de/impls.rs11
-rw-r--r--src/lib.rs23
-rw-r--r--src/ser/impls.rs4
16 files changed, 198 insertions, 77 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index e57ffb4..889a79f 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "ccf9c6fc072378ea8c4f15df1024e258d35d6e61"
+ "sha1": "e3058105f0b1a64018577b12ea19cd255644a17b"
},
"path_in_vcs": "serde"
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index a129ef0..1089f61 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,4 @@
-// This file is generated by cargo2android.py --config cargo2android.json.
+// This file is generated by cargo_embargo.
// Do not modify this file as changes will be overridden on upgrade.
package {
@@ -43,7 +43,7 @@ rust_library {
host_supported: true,
crate_name: "serde",
cargo_env_compat: true,
- cargo_pkg_version: "1.0.152",
+ cargo_pkg_version: "1.0.158",
srcs: ["src/lib.rs"],
edition: "2015",
features: [
@@ -58,6 +58,7 @@ rust_library {
"//apex_available:platform",
"//apex_available:anyapex",
],
+ product_available: true,
vendor_available: true,
min_sdk_version: "29",
}
@@ -67,7 +68,7 @@ rust_test {
host_supported: true,
crate_name: "serde",
cargo_env_compat: true,
- cargo_pkg_version: "1.0.152",
+ cargo_pkg_version: "1.0.158",
srcs: ["src/lib.rs"],
test_suites: ["general-tests"],
auto_gen_config: true,
@@ -84,3 +85,32 @@ rust_test {
],
proc_macros: ["libserde_derive"],
}
+
+rust_library_rlib {
+ name: "libserde_nostd",
+ crate_name: "serde",
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.0.158",
+ srcs: ["src/lib.rs"],
+ edition: "2015",
+ features: [
+ "alloc",
+ "derive",
+ "serde_derive",
+ ],
+ proc_macros: ["libserde_derive"],
+ apex_available: [
+ "//apex_available:platform",
+ "//apex_available:anyapex",
+ ],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "liballoc.rust_sysroot",
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
+ product_available: true,
+ vendor_available: true,
+ min_sdk_version: "29",
+}
diff --git a/Cargo.toml b/Cargo.toml
index 93acff3..e1e3e26 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,9 +10,9 @@
# See Cargo.toml.orig for the original contents.
[package]
-rust-version = "1.13"
+rust-version = "1.19"
name = "serde"
-version = "1.0.152"
+version = "1.0.158"
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>",
"David Tolnay <dtolnay@gmail.com>",
@@ -42,20 +42,21 @@ categories = [
license = "MIT OR Apache-2.0"
repository = "https://github.com/serde-rs/serde"
+[package.metadata.docs.rs]
+features = ["derive"]
+targets = ["x86_64-unknown-linux-gnu"]
+
[package.metadata.playground]
features = [
"derive",
"rc",
]
-[package.metadata.docs.rs]
-targets = ["x86_64-unknown-linux-gnu"]
-
[lib]
doc-scrape-examples = false
[dependencies.serde_derive]
-version = "=1.0.152"
+version = "=1.0.158"
optional = true
[dev-dependencies.serde_derive]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 9c3bc58..db7e6b1 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "serde"
-version = "1.0.152" # remember to update html_root_url and serde_derive dependency
+version = "1.0.158" # remember to update html_root_url and serde_derive dependency
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
build = "build.rs"
categories = ["encoding", "no-std"]
@@ -12,10 +12,10 @@ keywords = ["serde", "serialization", "no_std"]
license = "MIT OR Apache-2.0"
readme = "crates-io.md"
repository = "https://github.com/serde-rs/serde"
-rust-version = "1.13"
+rust-version = "1.19"
[dependencies]
-serde_derive = { version = "=1.0.152", optional = true, path = "../serde_derive" }
+serde_derive = { version = "=1.0.158", optional = true, path = "../serde_derive" }
[dev-dependencies]
serde_derive = { version = "1.0", path = "../serde_derive" }
@@ -27,6 +27,7 @@ doc-scrape-examples = false
features = ["derive", "rc"]
[package.metadata.docs.rs]
+features = ["derive"]
targets = ["x86_64-unknown-linux-gnu"]
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
index 16fe87b..1b5ec8b 100644
--- a/LICENSE-APACHE
+++ b/LICENSE-APACHE
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/METADATA b/METADATA
index eb4163f..13623c7 100644
--- a/METADATA
+++ b/METADATA
@@ -11,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/serde/serde-1.0.152.crate"
+ value: "https://static.crates.io/crates/serde/serde-1.0.158.crate"
}
- version: "1.0.152"
+ version: "1.0.158"
license_type: NOTICE
last_upgrade_date {
year: 2023
- month: 2
- day: 6
+ month: 3
+ day: 20
}
}
diff --git a/README.md b/README.md
index c3f6575..d53e572 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,13 @@
-# Serde &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.13+]][Rust 1.13] [![serde_derive: rustc 1.31+]][Rust 1.31]
+# Serde &emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.19+]][Rust 1.19] [![serde_derive: rustc 1.56+]][Rust 1.56]
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
[Latest Version]: https://img.shields.io/crates/v/serde.svg
[crates.io]: https://crates.io/crates/serde
-[serde: rustc 1.13+]: https://img.shields.io/badge/serde-rustc_1.13+-lightgray.svg
-[serde_derive: rustc 1.31+]: https://img.shields.io/badge/serde_derive-rustc_1.31+-lightgray.svg
-[Rust 1.13]: https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
-[Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
+[serde: rustc 1.19+]: https://img.shields.io/badge/serde-rustc_1.19+-lightgray.svg
+[serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg
+[Rust 1.19]: https://blog.rust-lang.org/2017/07/20/Rust-1.19.html
+[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
diff --git a/build.rs b/build.rs
index ccbddd2..929d8e1 100644
--- a/build.rs
+++ b/build.rs
@@ -78,11 +78,6 @@ fn main() {
println!("cargo:rustc-cfg=no_num_nonzero");
}
- // Current minimum supported version of serde_derive crate is Rust 1.31.
- if minor < 31 {
- println!("cargo:rustc-cfg=no_serde_derive");
- }
-
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
// stabilized in Rust 1.34:
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
@@ -94,6 +89,11 @@ fn main() {
println!("cargo:rustc-cfg=no_relaxed_trait_bounds");
}
+ // Current minimum supported version of serde_derive crate is Rust 1.56.
+ if minor < 56 {
+ println!("cargo:rustc-cfg=no_serde_derive");
+ }
+
// Support for #[cfg(target_has_atomic = "...")] stabilized in Rust 1.60.
if minor < 60 {
println!("cargo:rustc-cfg=no_target_has_atomic");
@@ -114,6 +114,12 @@ fn main() {
println!("cargo:rustc-cfg=no_std_atomic");
}
}
+
+ // Support for core::ffi::CStr and alloc::ffi::CString stabilized in Rust 1.64.
+ // https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#c-compatible-ffi-types-in-core-and-alloc
+ if minor < 64 {
+ println!("cargo:rustc-cfg=no_core_cstr");
+ }
}
fn rustc_minor_version() -> Option<u32> {
diff --git a/cargo2android.json b/cargo2android.json
deleted file mode 100644
index a6c47ed..0000000
--- a/cargo2android.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "apex-available": [
- "//apex_available:anyapex"
- ],
- "cfg-blocklist": [
- "std_atomic64"
- ],
- "dependencies": true,
- "device": true,
- "features": "default,derive,rc",
- "run": true,
- "tests": true,
- "vendor-available": true,
- "min_sdk_version": "29"
-}
diff --git a/cargo2rulesmk.json b/cargo2rulesmk.json
new file mode 100644
index 0000000..6610391
--- /dev/null
+++ b/cargo2rulesmk.json
@@ -0,0 +1,4 @@
+{
+ "features": "default,derive,alloc",
+ "patch": "patches/rules.mk.diff"
+} \ No newline at end of file
diff --git a/cargo_embargo.json b/cargo_embargo.json
new file mode 100644
index 0000000..550005b
--- /dev/null
+++ b/cargo_embargo.json
@@ -0,0 +1,34 @@
+{
+ "cfg_blocklist": [
+ "std_atomic64"
+ ],
+ "min_sdk_version": "29",
+ "run_cargo": false,
+ "variants": [
+ {
+ "features": [
+ "default",
+ "derive",
+ "rc"
+ ],
+ "tests": true
+ },
+ {
+ "features": [
+ "alloc",
+ "derive"
+ ],
+ "module_name_overrides": {
+ "libserde": "libserde_nostd"
+ },
+ "package": {
+ "serde": {
+ "alloc": true,
+ "force_rlib": true,
+ "host_supported": false,
+ "no_std": true
+ }
+ }
+ }
+ ]
+}
diff --git a/patches/rules.mk.diff b/patches/rules.mk.diff
new file mode 100644
index 0000000..71d3386
--- /dev/null
+++ b/patches/rules.mk.diff
@@ -0,0 +1,30 @@
+diff --git a/rules.mk b/rules.mk
+index 442c6fc..986ff0d 100644
+--- a/rules.mk
++++ b/rules.mk
+@@ -13,9 +13,25 @@ MODULE_RUSTFLAGS += \
+ --cfg 'feature="default"' \
+ --cfg 'feature="derive"' \
+ --cfg 'feature="serde_derive"' \
++
++ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true)
++
++MODULE_RUSTFLAGS += \
+ --cfg 'feature="std"' \
+
++else
++
++# avoid cyclic dependence by adding dependencies manually
++MODULE_ADD_IMPLICIT_DEPS := false
++
++MODULE_DEPS := \
++ trusty/user/base/lib/libcore-rust/ \
++ trusty/user/base/lib/libcompiler_builtins-rust/ \
++
++endif
++
+ MODULE_LIBRARY_DEPS := \
++ trusty/user/base/lib/liballoc-rust \
+ external/rust/crates/serde_derive \
+
+ include make/library.mk
diff --git a/rules.mk b/rules.mk
new file mode 100644
index 0000000..140d8bc
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,37 @@
+# This file is generated by cargo2rulesmk.py --run --config cargo2rulesmk.json.
+# Do not modify this file as changes will be overridden on upgrade.
+
+LOCAL_DIR := $(GET_LOCAL_DIR)
+MODULE := $(LOCAL_DIR)
+MODULE_CRATE_NAME := serde
+MODULE_SRCS := \
+ $(LOCAL_DIR)/src/lib.rs \
+
+MODULE_RUST_EDITION := 2015
+MODULE_RUSTFLAGS += \
+ --cfg 'feature="alloc"' \
+ --cfg 'feature="default"' \
+ --cfg 'feature="derive"' \
+ --cfg 'feature="serde_derive"' \
+
+ifeq ($(call TOBOOL,$(TRUSTY_USERSPACE)),true)
+
+MODULE_RUSTFLAGS += \
+ --cfg 'feature="std"' \
+
+else
+
+# avoid cyclic dependence by adding dependencies manually
+MODULE_ADD_IMPLICIT_DEPS := false
+
+MODULE_DEPS := \
+ trusty/user/base/lib/libcore-rust/ \
+ trusty/user/base/lib/libcompiler_builtins-rust/ \
+
+endif
+
+MODULE_LIBRARY_DEPS := \
+ trusty/user/base/lib/liballoc-rust \
+ external/rust/crates/serde_derive \
+
+include make/library.mk
diff --git a/src/de/impls.rs b/src/de/impls.rs
index a257d9e..a2e2c48 100644
--- a/src/de/impls.rs
+++ b/src/de/impls.rs
@@ -666,10 +666,10 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a [u8] {
////////////////////////////////////////////////////////////////////////////////
-#[cfg(feature = "std")]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
struct CStringVisitor;
-#[cfg(feature = "std")]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
impl<'de> Visitor<'de> for CStringVisitor {
type Value = CString;
@@ -720,7 +720,7 @@ impl<'de> Visitor<'de> for CStringVisitor {
}
}
-#[cfg(feature = "std")]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
impl<'de> Deserialize<'de> for CString {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
@@ -747,7 +747,10 @@ macro_rules! forwarded_impl {
}
}
-#[cfg(all(feature = "std", not(no_de_boxed_c_str)))]
+#[cfg(all(
+ any(feature = "std", all(not(no_core_cstr), feature = "alloc")),
+ not(no_de_boxed_c_str)
+))]
forwarded_impl!((), Box<CStr>, CString::into_boxed_c_str);
#[cfg(not(no_core_reverse))]
diff --git a/src/lib.rs b/src/lib.rs
index e4bc7c8..8ba1473 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -45,6 +45,8 @@
//! definition.
//! - [JSON5], a superset of JSON including some productions from ES5.
//! - [URL] query strings, in the x-www-form-urlencoded format.
+//! - [Starlark], the format used for describing build targets by the Bazel and
+//! Buck build systems. *(serialization only)*
//! - [Envy], a way to deserialize environment variables into Rust structs.
//! *(deserialization only)*
//! - [Envy Store], a way to deserialize [AWS Parameter Store] parameters into
@@ -74,6 +76,7 @@
//! [Avro]: https://docs.rs/apache-avro
//! [JSON5]: https://github.com/callum-oakley/json5-rs
//! [URL]: https://docs.rs/serde_qs
+//! [Starlark]: https://github.com/dtolnay/serde-starlark
//! [Envy]: https://github.com/softprops/envy
//! [Envy Store]: https://github.com/softprops/envy-store
//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -90,7 +93,7 @@
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.152")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.158")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Unstable functionality only if the user asks for it. For tracking and
@@ -127,6 +130,7 @@
derive_partial_eq_without_eq,
enum_glob_use,
explicit_auto_deref,
+ let_underscore_untyped,
map_err_ignore,
new_without_default,
result_unit_err,
@@ -215,13 +219,23 @@ mod lib {
#[cfg(feature = "std")]
pub use std::collections::{BTreeMap, BTreeSet, BinaryHeap, LinkedList, VecDeque};
+ #[cfg(all(not(no_core_cstr), not(feature = "std")))]
+ pub use core::ffi::CStr;
+ #[cfg(feature = "std")]
+ pub use std::ffi::CStr;
+
+ #[cfg(all(not(no_core_cstr), feature = "alloc", not(feature = "std")))]
+ pub use alloc::ffi::CString;
+ #[cfg(feature = "std")]
+ pub use std::ffi::CString;
+
#[cfg(feature = "std")]
pub use std::{error, net};
#[cfg(feature = "std")]
pub use std::collections::{HashMap, HashSet};
#[cfg(feature = "std")]
- pub use std::ffi::{CStr, CString, OsStr, OsString};
+ pub use std::ffi::{OsStr, OsString};
#[cfg(feature = "std")]
pub use std::hash::{BuildHasher, Hash};
#[cfg(feature = "std")]
@@ -324,9 +338,10 @@ mod std_error;
#[allow(unused_imports)]
#[macro_use]
extern crate serde_derive;
+
+/// Derive macro available if serde is built with `features = ["derive"]`.
#[cfg(feature = "serde_derive")]
-#[doc(hidden)]
-pub use serde_derive::*;
+pub use serde_derive::{Deserialize, Serialize};
#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))]
mod actually_private {
diff --git a/src/ser/impls.rs b/src/ser/impls.rs
index da26772..a79326e 100644
--- a/src/ser/impls.rs
+++ b/src/ser/impls.rs
@@ -72,7 +72,7 @@ impl<'a> Serialize for fmt::Arguments<'a> {
////////////////////////////////////////////////////////////////////////////////
-#[cfg(feature = "std")]
+#[cfg(any(feature = "std", not(no_core_cstr)))]
impl Serialize for CStr {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -83,7 +83,7 @@ impl Serialize for CStr {
}
}
-#[cfg(feature = "std")]
+#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))]
impl Serialize for CString {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>