From d9965cc1010717218eee37b3c840704fb3d93f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Wed, 5 Apr 2023 14:37:24 +0300 Subject: [PATCH] hex-literal: enforce const evaluation --- Cargo.lock | 10 +++++----- hex-literal/CHANGELOG.md | 6 ++++++ hex-literal/Cargo.toml | 2 +- hex-literal/src/lib.rs | 4 +++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8489ed9f..3edcd864 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" [[package]] name = "hex-literal" -version = "0.4.0" +version = "0.4.1" [[package]] name = "hybrid-array" @@ -115,9 +115,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" [[package]] name = "opaque-debug" @@ -125,9 +125,9 @@ version = "0.3.0" [[package]] name = "proc-macro2" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0dd4be24fcdcfeaa12a432d588dc59bbad6cad3510c67e74a2b6b2fc950564" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] diff --git a/hex-literal/CHANGELOG.md b/hex-literal/CHANGELOG.md index 517eb2b9..5d576560 100644 --- a/hex-literal/CHANGELOG.md +++ b/hex-literal/CHANGELOG.md @@ -4,6 +4,12 @@ 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). +## 0.4.1 (2023-04-05) +### Changed +- Enforce const evaluation ([#886]) + +[#886]: https://github.com/RustCrypto/utils/pull/886 + ## 0.4.0 (2023-04-02) ### Changed - Disallow comments inside hex strings ([#816]) diff --git a/hex-literal/Cargo.toml b/hex-literal/Cargo.toml index a4062093..ad07ffb1 100644 --- a/hex-literal/Cargo.toml +++ b/hex-literal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hex-literal" -version = "0.4.0" +version = "0.4.1" authors = ["RustCrypto Developers"] license = "MIT OR Apache-2.0" description = "Macro for converting hexadecimal string to a byte array at compile time" diff --git a/hex-literal/src/lib.rs b/hex-literal/src/lib.rs index 4b31b071..f6c8fac7 100644 --- a/hex-literal/src/lib.rs +++ b/hex-literal/src/lib.rs @@ -81,6 +81,8 @@ pub const fn decode(strings: &[&[u8]]) -> [u8; LEN] { macro_rules! hex { ($($s:literal)*) => {{ const STRINGS: &[&'static [u8]] = &[$($s.as_bytes(),)*]; - $crate::decode::<{ $crate::len(STRINGS) }>(STRINGS) + const LEN: usize = $crate::len(STRINGS); + const RES: [u8; LEN] = $crate::decode(STRINGS); + RES }}; }