Backed out changeset 908e6fbd94a0 (bug 1932319) for causing SM build bustages @ rust.mk . CLOSED TREE

This commit is contained in:
Alexandru Marc 2024-11-22 13:59:03 +02:00
parent 43e92147e1
commit 92ea7df894
10 changed files with 21 additions and 50 deletions

4
Cargo.lock generated
View File

@ -7548,9 +7548,9 @@ dependencies = [
[[package]]
name = "zerovec-derive"
version = "0.10.3"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7"
dependencies = [
"proc-macro2",
"quote",

View File

@ -5737,11 +5737,6 @@ who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
criteria = "safe-to-deploy"
delta = "0.10.1 -> 0.10.2"
[[audits.zerovec-derive]]
who = "Max Inden <mail@max-inden.de>"
criteria = "safe-to-deploy"
delta = "0.10.2 -> 0.10.3"
[[audits.zip]]
who = "Alex Franchuk <afranchuk@mozilla.com>"
criteria = "safe-to-deploy"

View File

@ -1 +1 @@
{"files":{"Cargo.lock":"fb1408ba4a7abcd164b9228b7b4096e0946bdd9dd518bd680c8dcbfe141f0351","Cargo.toml":"d60a5ef4e2cb4025065a294c15964f5ad5d2ad4923e339321f4dbb7b7ef11427","LICENSE":"f367c1b8e1aa262435251e442901da4607b4650e0e63a026f5044473ecfb90f2","README.md":"bacbc17b2cb457c169257f5e22c78a45d1c4a399eadae383f7732af909616ebc","examples/derives.rs":"eda3a1ad0106755bdf71f320d31ad619c62d04e00dba400205ab3072824198b5","examples/make.rs":"709829d9aa1fa1d023437dfd8169183690629b71e65cc1316b1f4bf767588cc6","examples/make_var.rs":"933c0ecb44f69f9081e7866a1a782d8501ad947d87b9e4cab6947640c28c3998","src/lib.rs":"029d2b251b8279e7c85d9cc8efb6cad5188da9464b0a27e9de3dd119f4ffef2e","src/make_ule.rs":"632d21f065728cc3cbdf6ae2cce9181ec72cd54ecdb51baf72d25624ebc1b4d6","src/make_varule.rs":"756384f6f8ae5a40e2a1b02f47bc804f110a907413ea6470152cca13ea912202","src/ule.rs":"f70d237e2ab1732a83e9f6e9cb22d5059f2b3daa2f3616679a9b48555faf70da","src/utils.rs":"72b0d93de4592d1ac4ccd672239385975e7075ff88ea2e1f604cf974d8642f4c","src/varule.rs":"40ddff54a63c902774f75a586dc0d704862e503d270aee3eadcddb8c738b7e67"},"package":"6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"}
{"files":{"Cargo.lock":"d4c03dffac3217dba9bb04c501680856f645ca4916a6908190db93f5e24bc56e","Cargo.toml":"755adc6399988b491e8854b3b383fab1da608b50c61e2eec0f598c9e85d91732","LICENSE":"f367c1b8e1aa262435251e442901da4607b4650e0e63a026f5044473ecfb90f2","README.md":"bacbc17b2cb457c169257f5e22c78a45d1c4a399eadae383f7732af909616ebc","examples/derives.rs":"2541311f2b532301ab8600927fb2d12a842166ce98d57879997df12dcb928dd2","examples/make.rs":"709829d9aa1fa1d023437dfd8169183690629b71e65cc1316b1f4bf767588cc6","examples/make_var.rs":"933c0ecb44f69f9081e7866a1a782d8501ad947d87b9e4cab6947640c28c3998","src/lib.rs":"029d2b251b8279e7c85d9cc8efb6cad5188da9464b0a27e9de3dd119f4ffef2e","src/make_ule.rs":"5e1abcae7f8ffda8c472f19e4ce2543dc9b4841e644750d2ecb85fcbe0c836f8","src/make_varule.rs":"756384f6f8ae5a40e2a1b02f47bc804f110a907413ea6470152cca13ea912202","src/ule.rs":"1f0a46ff39e43bb19deb9e9a06289350096d4e6ca3f33cb76fec3c84c4a439d8","src/utils.rs":"1b20508f2f61da6c27a628b70ba38fe952cafb065321af0b1ff0f7b05b80211e","src/varule.rs":"b0642df70023b2f04aca692010f6b2a81fd3f3db8612dbae072a200eb04f0913"},"package":"97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7"}

View File

@ -91,7 +91,7 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "zerovec-derive"
version = "0.10.3"
version = "0.10.2"
dependencies = [
"bincode",
"proc-macro2",

View File

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "zerovec-derive"
version = "0.10.3"
version = "0.10.2"
authors = ["Manish Goregaokar <manishsmail@gmail.com>"]
description = "Custom derive for the zerovec crate"
readme = "README.md"

View File

@ -6,7 +6,7 @@ use zerovec::ule::AsULE;
use zerovec::ule::EncodeAsVarULE;
use zerovec::*;
#[repr(C, packed)]
#[repr(packed)]
#[derive(ule::ULE, Copy, Clone)]
pub struct FooULE {
a: u8,
@ -40,7 +40,7 @@ impl AsULE for Foo {
}
}
#[repr(C, packed)]
#[repr(packed)]
#[derive(ule::VarULE)]
pub struct RelationULE {
/// This maps to (AndOr, Polarity, Operand),

View File

@ -83,7 +83,7 @@ fn make_ule_enum_impl(
attrs: ZeroVecAttrs,
) -> TokenStream2 {
// We could support more int reprs in the future if needed
if !utils::ReprInfo::compute(&input.attrs).u8 {
if !utils::has_valid_repr(&input.attrs, |r| r == "u8") {
return Error::new(
input.span(),
"#[make_ule] can only be applied to #[repr(u8)] enums",

View File

@ -10,10 +10,10 @@ use syn::spanned::Spanned;
use syn::{Data, DeriveInput, Error};
pub fn derive_impl(input: &DeriveInput) -> TokenStream2 {
if !utils::ReprInfo::compute(&input.attrs).cpacked_or_transparent() {
if !utils::has_valid_repr(&input.attrs, |r| r == "packed" || r == "transparent") {
return Error::new(
input.span(),
"derive(ULE) must be applied to a #[repr(C, packed)] or #[repr(transparent)] type",
"derive(ULE) must be applied to a #[repr(packed)] or #[repr(transparent)] type",
)
.to_compile_error();
}

View File

@ -11,38 +11,14 @@ use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{Attribute, Error, Field, Fields, Ident, Index, Result, Token};
#[derive(Default)]
pub struct ReprInfo {
pub c: bool,
pub transparent: bool,
pub u8: bool,
pub packed: bool,
}
impl ReprInfo {
pub fn compute(attrs: &[Attribute]) -> Self {
let mut info = ReprInfo::default();
for attr in attrs.iter().filter(|a| a.path().is_ident("repr")) {
if let Ok(pieces) = attr.parse_args::<IdentListAttribute>() {
for piece in pieces.idents.iter() {
if piece == "C" || piece == "c" {
info.c = true;
} else if piece == "transparent" {
info.transparent = true;
} else if piece == "packed" {
info.packed = true;
} else if piece == "u8" {
info.u8 = true;
}
}
}
}
info
}
pub fn cpacked_or_transparent(self) -> bool {
(self.c && self.packed) || self.transparent
}
// Check that there are repr attributes satisfying the given predicate
pub fn has_valid_repr(attrs: &[Attribute], predicate: impl Fn(&Ident) -> bool + Copy) -> bool {
attrs.iter().filter(|a| a.path().is_ident("repr")).any(|a| {
a.parse_args::<IdentListAttribute>()
.ok()
.and_then(|s| s.idents.iter().find(|s| predicate(s)).map(|_| ()))
.is_some()
})
}
// An attribute that is a list of idents
@ -84,7 +60,7 @@ pub fn repr_for(f: &Fields) -> TokenStream2 {
if f.len() == 1 {
quote!(transparent)
} else {
quote!(C, packed)
quote!(packed)
}
}

View File

@ -15,10 +15,10 @@ pub fn derive_impl(
input: &DeriveInput,
custom_varule_validator: Option<TokenStream2>,
) -> TokenStream2 {
if !utils::ReprInfo::compute(&input.attrs).cpacked_or_transparent() {
if !utils::has_valid_repr(&input.attrs, |r| r == "packed" || r == "transparent") {
return Error::new(
input.span(),
"derive(VarULE) must be applied to a #[repr(C, packed)] or #[repr(transparent)] type",
"derive(VarULE) must be applied to a #[repr(packed)] or #[repr(transparent)] type",
)
.to_compile_error();
}