diff options
author | Andrew Walbran <qwandor@google.com> | 2023-11-17 18:42:01 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-11-17 18:42:01 +0000 |
commit | 32ebcf2639c6cba518c204b010dac2b57e138f0d (patch) | |
tree | 3180582fcfbfa56994652df39b2f5c9acb66175e | |
parent | 31264e644e76b1467419e9d7d2fae24e41e04bf7 (diff) | |
parent | 212eea9fb67d9bcbebae1fbf1d9ee1bd8b3e8e60 (diff) | |
download | zeroize_derive-32ebcf2639c6cba518c204b010dac2b57e138f0d.tar.gz |
Upgrade zeroize_derive to 1.4.2 am: e223f48c35 am: 212eea9fb6
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/zeroize_derive/+/2835931
Change-Id: I965b8ef25965328e13e31ef0c812d41d11382449
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 6 | ||||
-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-- | patches/proc_macro.patch | 12 | ||||
-rw-r--r-- | rules.mk | 5 | ||||
-rw-r--r-- | src/lib.rs | 50 |
11 files changed, 111 insertions, 29 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 @@ -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/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 } |