diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-18 02:15:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-11-18 02:15:24 +0000 |
commit | a2b61cf10d15dcacc950bfb42b3364c6b55ed2aa (patch) | |
tree | a24a2b30a087eae911acba5fa66dcaaa600ff636 | |
parent | 076cdfbeceb27fd340f802407a7eec3f9d729e2c (diff) | |
parent | d7caa0763c2f87c5bf29ff50bceae5a28c6c82c4 (diff) | |
download | zeroize_derive-android14-qpr2-s1-release.tar.gz |
Snap for 11117647 from d7caa0763c2f87c5bf29ff50bceae5a28c6c82c4 to 24Q1-releaseandroid-14.0.0_r37android-14.0.0_r36android-14.0.0_r35android-14.0.0_r34android-14.0.0_r33android-14.0.0_r32android-14.0.0_r31android-14.0.0_r30android-14.0.0_r29android14-qpr2-s5-releaseandroid14-qpr2-s4-releaseandroid14-qpr2-s3-releaseandroid14-qpr2-s2-releaseandroid14-qpr2-s1-releaseandroid14-qpr2-release
Change-Id: I3d50648e951c0c711de6d0252dc53659d093e1d6
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 8 | ||||
-rw-r--r-- | CHANGELOG.md | 23 | ||||
-rw-r--r-- | Cargo.toml | 16 | ||||
-rw-r--r-- | Cargo.toml.orig | 8 | ||||
-rw-r--r-- | LICENSE-MIT | 2 | ||||
-rw-r--r-- | METADATA | 12 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | cargo2android.json | 5 | ||||
-rw-r--r-- | cargo_embargo.json | 10 | ||||
-rw-r--r-- | patches/proc_macro.patch | 12 | ||||
-rw-r--r-- | rules.mk | 5 | ||||
-rw-r--r-- | src/lib.rs | 50 |
13 files changed, 122 insertions, 35 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1c4f96f..b2a1b17 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "fdc19f7f0c5590dcd003982144b9af772829c654" + "sha1": "4ac07e8e8d02c61219c7ba3633e15eabfdb0fc11" }, "path_in_vcs": "zeroize/derive" }
\ No newline at end of file @@ -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 { @@ -24,7 +24,7 @@ rust_proc_macro { name: "libzeroize_derive", crate_name: "zeroize_derive", cargo_env_compat: true, - cargo_pkg_version: "1.3.3", + cargo_pkg_version: "1.4.2", srcs: ["src/lib.rs"], edition: "2021", rustlibs: [ @@ -33,15 +33,13 @@ rust_proc_macro { "libsyn", ], compile_multilib: "first", - product_available: true, - vendor_available: true, } rust_test_host { name: "zeroize_derive_test_src_lib", crate_name: "zeroize_derive", cargo_env_compat: true, - cargo_pkg_version: "1.3.3", + cargo_pkg_version: "1.4.2", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, diff --git a/CHANGELOG.md b/CHANGELOG.md index 4191342..8b950c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.4.2 (2023-03-30) +### Changed +- Inject where clauses; skip unused ([#882]) + +[#882]: https://github.com/RustCrypto/utils/pull/882 + +## 1.4.1 (2023-03-27) +### Changed +- Do not automatically inject bounds ([#879]) + +[#879]: https://github.com/RustCrypto/utils/pull/879 + +## 1.4.0 (2023-03-26) +### Changed +- 2021 edition upgrade; MSRV 1.56 ([#869]) +- Bump `syn` to v2 ([#858]) + +### Removed +- `synstructure` dependency ([#858]) + +[#858]: https://github.com/RustCrypto/utils/pull/858 +[#869]: https://github.com/RustCrypto/utils/pull/869 + ## 1.3.3 (2022-11-30) ### Fixed - Deriving `ZeroizeOnDrop` on items with generics ([#787]) @@ -10,9 +10,10 @@ # See Cargo.toml.orig for the original contents. [package] -edition = "2018" +edition = "2021" +rust-version = "1.56" name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" authors = ["The RustCrypto Project Developers"] description = "Custom derive support for zeroize" readme = "README.md" @@ -31,6 +32,7 @@ categories = [ ] license = "Apache-2.0 OR MIT" repository = "https://github.com/RustCrypto/utils/tree/master/zeroize/derive" +resolver = "1" [package.metadata.docs.rs] rustdoc-args = ["--document-private-items"] @@ -45,7 +47,9 @@ version = "1" version = "1" [dependencies.syn] -version = "1" - -[dependencies.synstructure] -version = "0.12.2" +version = "2" +features = [ + "full", + "extra-traits", + "visit", +] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index c33fbcf..07dab7f 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,14 +1,15 @@ [package] name = "zeroize_derive" description = "Custom derive support for zeroize" -version = "1.3.3" +version = "1.4.2" authors = ["The RustCrypto Project Developers"] license = "Apache-2.0 OR MIT" repository = "https://github.com/RustCrypto/utils/tree/master/zeroize/derive" readme = "README.md" categories = ["cryptography", "memory-management", "no-std", "os"] keywords = ["memory", "memset", "secure", "volatile", "zero"] -edition = "2018" +edition = "2021" +rust-version = "1.56" [lib] proc-macro = true @@ -16,8 +17,7 @@ proc-macro = true [dependencies] proc-macro2 = "1" quote = "1" -syn = "1" -synstructure = "0.12.2" +syn = {version = "2", features = ["full", "extra-traits", "visit"]} [package.metadata.docs.rs] rustdoc-args = ["--document-private-items"] diff --git a/LICENSE-MIT b/LICENSE-MIT index 4281628..de3a9c5 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2021 The RustCrypto Project Developers +Copyright (c) 2019-2023 The RustCrypto Project Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1,6 +1,6 @@ # This project was upgraded with external_updater. # Usage: tools/external_updater/updater.sh update rust/crates/zeroize_derive -# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md +# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md name: "zeroize_derive" description: "Custom derive support for zeroize" @@ -11,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/zeroize_derive/zeroize_derive-1.3.3.crate" + value: "https://static.crates.io/crates/zeroize_derive/zeroize_derive-1.4.2.crate" } - version: "1.3.3" + version: "1.4.2" license_type: NOTICE last_upgrade_date { - year: 2022 - month: 12 - day: 19 + year: 2023 + month: 11 + day: 17 } } @@ -13,7 +13,7 @@ See [zeroize] crate for documentation. ## Minimum Supported Rust Version -Rust **1.51** or newer. +Rust **1.56** or newer. In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's SemVer guarantees), however when we do it will be accompanied by @@ -39,7 +39,7 @@ dual licensed as above, without any additional terms or conditions. [crate-image]: https://img.shields.io/crates/v/zeroize_derive.svg [crate-link]: https://crates.io/crates/zeroize_derive [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.51+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg [build-image]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml/badge.svg [build-link]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml diff --git a/cargo2android.json b/cargo2android.json deleted file mode 100644 index 2e184ce..0000000 --- a/cargo2android.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "host-first-multilib": true, - "tests": true, - "run": true -} diff --git a/cargo_embargo.json b/cargo_embargo.json new file mode 100644 index 0000000..b048231 --- /dev/null +++ b/cargo_embargo.json @@ -0,0 +1,10 @@ +{ + "package": { + "zeroize_derive": { + "device_supported": false, + "host_first_multilib": true + } + }, + "run_cargo": false, + "tests": true +} diff --git a/patches/proc_macro.patch b/patches/proc_macro.patch new file mode 100644 index 0000000..de37122 --- /dev/null +++ b/patches/proc_macro.patch @@ -0,0 +1,12 @@ +diff --git a/src/lib.rs b/src/lib.rs +index 2f31fc6..d1fe77e 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -3,6 +3,7 @@ + #![crate_type = "proc-macro"] + #![forbid(unsafe_code)] + #![warn(rust_2018_idioms, trivial_casts, unused_qualifications)] ++extern crate proc_macro; + + use proc_macro2::{Ident, TokenStream}; + use quote::{format_ident, quote}; @@ -1,4 +1,4 @@ -# This file is generated by cargo2rulesmk.py --run --features . +# This file is generated by cargo2rulesmk.py --run. # Do not modify this file as changes will be overridden on upgrade. LOCAL_DIR := $(GET_LOCAL_DIR) @@ -8,11 +8,10 @@ MODULE_RUST_CRATE_TYPES := proc-macro MODULE_SRCS := \ $(LOCAL_DIR)/src/lib.rs \ -MODULE_RUST_EDITION := 2018 +MODULE_RUST_EDITION := 2021 MODULE_LIBRARY_DEPS := \ external/rust/crates/proc-macro2 \ external/rust/crates/quote \ external/rust/crates/syn \ - external/rust/crates/synstructure \ include make/library.mk @@ -9,8 +9,10 @@ use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; use syn::{ parse::{Parse, ParseStream}, + parse_quote, punctuated::Punctuated, token::Comma, + visit::Visit, Attribute, Data, DeriveInput, Expr, ExprLit, Field, Fields, Lit, Meta, Result, Variant, WherePredicate, }; @@ -37,12 +39,19 @@ pub fn derive_zeroize(input: proc_macro::TokenStream) -> proc_macro::TokenStream fn derive_zeroize_impl(input: DeriveInput) -> TokenStream { let attributes = ZeroizeAttrs::parse(&input); + let mut generics = input.generics.clone(); + let extra_bounds = match attributes.bound { Some(bounds) => bounds.0, - None => Default::default(), + None => attributes + .auto_params + .iter() + .map(|type_param| -> WherePredicate { + parse_quote! {#type_param: Zeroize} + }) + .collect(), }; - let mut generics = input.generics.clone(); generics.make_where_clause().predicates.extend(extra_bounds); let ty_name = &input.ident; @@ -118,6 +127,8 @@ struct ZeroizeAttrs { drop: bool, /// Custom bounds as defined by the user bound: Option<Bounds>, + /// Type parameters in use by fields + auto_params: Vec<Ident>, } /// Parsing helper for custom bounds @@ -129,10 +140,37 @@ impl Parse for Bounds { } } +struct BoundAccumulator<'a> { + generics: &'a syn::Generics, + params: Vec<Ident>, +} + +impl<'ast> Visit<'ast> for BoundAccumulator<'ast> { + fn visit_path(&mut self, path: &'ast syn::Path) { + if path.segments.len() != 1 { + return; + } + + if let Some(segment) = path.segments.first() { + for param in &self.generics.params { + if let syn::GenericParam::Type(type_param) = param { + if type_param.ident == segment.ident && !self.params.contains(&segment.ident) { + self.params.push(type_param.ident.clone()); + } + } + } + } + } +} + impl ZeroizeAttrs { /// Parse attributes from the incoming AST fn parse(input: &DeriveInput) -> Self { let mut result = Self::default(); + let mut bound_accumulator = BoundAccumulator { + generics: &input.generics, + params: Vec::new(), + }; for attr in &input.attrs { result.parse_attr(attr, None, None); @@ -148,6 +186,9 @@ impl ZeroizeAttrs { for attr in &field.attrs { result.parse_attr(attr, Some(variant), Some(field)); } + if !attr_skip(&field.attrs) { + bound_accumulator.visit_type(&field.ty); + } } } } @@ -156,11 +197,16 @@ impl ZeroizeAttrs { for attr in &field.attrs { result.parse_attr(attr, None, Some(field)); } + if !attr_skip(&field.attrs) { + bound_accumulator.visit_type(&field.ty); + } } } syn::Data::Union(union_) => panic!("Unsupported untagged union {:?}", union_), } + result.auto_params = bound_accumulator.params; + result } |