From 905535df03f827b75a3635e0b78150b200a17160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 13 Feb 2026 11:50:12 +0100 Subject: [PATCH 1/5] Remove cfgs based on nonexisting features --- src/data_model.rs | 1 - src/lib.rs | 13 ------------- src/targets.rs | 15 --------------- src/triple.rs | 1 - 4 files changed, 30 deletions(-) diff --git a/src/data_model.rs b/src/data_model.rs index 0954add..696f15d 100644 --- a/src/data_model.rs +++ b/src/data_model.rs @@ -40,7 +40,6 @@ impl Size { /// /// See also https://en.cppreference.com/w/c/language/arithmetic_types #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] pub enum CDataModel { /// The data model used most commonly on Win16. `long` and `pointer` are 32 bits. LP32, diff --git a/src/lib.rs b/src/lib.rs index 2cb1c58..8a4e7de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,19 +2,6 @@ #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces)] -#![cfg_attr( - feature = "cargo-clippy", - warn( - clippy::float_arithmetic, - clippy::mut_mut, - clippy::nonminimal_bool, - clippy::option_map_unwrap_or, - clippy::option_map_unwrap_or_else, - clippy::print_stdout, - clippy::unicode_not_nfc, - clippy::use_self, - ) -)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/src/targets.rs b/src/targets.rs index c908269..0c74104 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -11,7 +11,6 @@ use core::str::FromStr; /// The "architecture" field, which in some cases also specifies a specific /// subarchitecture. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Architecture { @@ -60,7 +59,6 @@ pub enum Architecture { Z80(Z80Architecture), } -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum ArmArchitecture { @@ -110,7 +108,6 @@ pub enum ArmArchitecture { Thumbv8mMain, } -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Aarch64Architecture { @@ -118,7 +115,6 @@ pub enum Aarch64Architecture { Aarch64be, } -// #[cfg_attr(feature = "rust_1_40", non_exhaustive)] // #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] // #[allow(missing_docs)] // pub enum ArmFpu { @@ -389,7 +385,6 @@ impl Aarch64Architecture { } } -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum CleverArchitecture { @@ -410,7 +405,6 @@ impl CleverArchitecture { } /// An enum for all 32-bit RISC-V architectures. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Riscv32Architecture { @@ -443,7 +437,6 @@ impl Riscv32Architecture { } /// An enum for all 64-bit RISC-V architectures. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Riscv64Architecture { @@ -468,7 +461,6 @@ impl Riscv64Architecture { } /// An enum for all 32-bit x86 architectures. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum X86_32Architecture { @@ -491,7 +483,6 @@ impl X86_32Architecture { } /// An enum for all 32-bit MIPS architectures (not just "MIPS32"). -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Mips32Architecture { @@ -516,7 +507,6 @@ impl Mips32Architecture { } /// An enum for all 64-bit MIPS architectures (not just "MIPS64"). -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Mips64Architecture { @@ -541,7 +531,6 @@ impl Mips64Architecture { } #[cfg(feature = "arch_z80")] -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Z80Architecture { @@ -612,7 +601,6 @@ impl Hash for CustomVendor { /// The "vendor" field, which in practice is little more than an arbitrary /// modifier. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Vendor { @@ -687,7 +675,6 @@ pub struct DeploymentTarget { /// LLVM's Apple triples may optionally include the [deployment target]. /// /// [deployment target]: DeploymentTarget -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum OperatingSystem { @@ -833,7 +820,6 @@ impl OperatingSystem { /// The "environment" field, which specifies an ABI environment on top of the /// operating system. In many configurations, this field is omitted, and the /// environment is implied by the operating system. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Environment { @@ -921,7 +907,6 @@ impl Environment { /// The "binary format" field, which is usually omitted, and the binary format /// is implied by the other fields. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum BinaryFormat { diff --git a/src/triple.rs b/src/triple.rs index d92ea67..a8f2758 100644 --- a/src/triple.rs +++ b/src/triple.rs @@ -52,7 +52,6 @@ impl PointerWidth { /// The calling convention, which specifies things like which registers are /// used for passing arguments, which registers are callee-saved, and so on. -#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum CallingConvention { /// "System V", which is used on most Unix-like platfoms. Note that the From 929377b1e238018ffb30db934a70614beead9a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 13 Feb 2026 12:03:37 +0100 Subject: [PATCH 2/5] Revert "Remove cfgs based on nonexisting features" This reverts commit 905535df03f827b75a3635e0b78150b200a17160. --- src/data_model.rs | 1 + src/lib.rs | 13 +++++++++++++ src/targets.rs | 15 +++++++++++++++ src/triple.rs | 1 + 4 files changed, 30 insertions(+) diff --git a/src/data_model.rs b/src/data_model.rs index 696f15d..0954add 100644 --- a/src/data_model.rs +++ b/src/data_model.rs @@ -40,6 +40,7 @@ impl Size { /// /// See also https://en.cppreference.com/w/c/language/arithmetic_types #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] pub enum CDataModel { /// The data model used most commonly on Win16. `long` and `pointer` are 32 bits. LP32, diff --git a/src/lib.rs b/src/lib.rs index 8a4e7de..2cb1c58 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,19 @@ #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces)] +#![cfg_attr( + feature = "cargo-clippy", + warn( + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::print_stdout, + clippy::unicode_not_nfc, + clippy::use_self, + ) +)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] diff --git a/src/targets.rs b/src/targets.rs index 0c74104..c908269 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -11,6 +11,7 @@ use core::str::FromStr; /// The "architecture" field, which in some cases also specifies a specific /// subarchitecture. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Architecture { @@ -59,6 +60,7 @@ pub enum Architecture { Z80(Z80Architecture), } +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum ArmArchitecture { @@ -108,6 +110,7 @@ pub enum ArmArchitecture { Thumbv8mMain, } +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Aarch64Architecture { @@ -115,6 +118,7 @@ pub enum Aarch64Architecture { Aarch64be, } +// #[cfg_attr(feature = "rust_1_40", non_exhaustive)] // #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] // #[allow(missing_docs)] // pub enum ArmFpu { @@ -385,6 +389,7 @@ impl Aarch64Architecture { } } +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum CleverArchitecture { @@ -405,6 +410,7 @@ impl CleverArchitecture { } /// An enum for all 32-bit RISC-V architectures. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Riscv32Architecture { @@ -437,6 +443,7 @@ impl Riscv32Architecture { } /// An enum for all 64-bit RISC-V architectures. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Riscv64Architecture { @@ -461,6 +468,7 @@ impl Riscv64Architecture { } /// An enum for all 32-bit x86 architectures. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum X86_32Architecture { @@ -483,6 +491,7 @@ impl X86_32Architecture { } /// An enum for all 32-bit MIPS architectures (not just "MIPS32"). +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Mips32Architecture { @@ -507,6 +516,7 @@ impl Mips32Architecture { } /// An enum for all 64-bit MIPS architectures (not just "MIPS64"). +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Mips64Architecture { @@ -531,6 +541,7 @@ impl Mips64Architecture { } #[cfg(feature = "arch_z80")] +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Z80Architecture { @@ -601,6 +612,7 @@ impl Hash for CustomVendor { /// The "vendor" field, which in practice is little more than an arbitrary /// modifier. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Vendor { @@ -675,6 +687,7 @@ pub struct DeploymentTarget { /// LLVM's Apple triples may optionally include the [deployment target]. /// /// [deployment target]: DeploymentTarget +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum OperatingSystem { @@ -820,6 +833,7 @@ impl OperatingSystem { /// The "environment" field, which specifies an ABI environment on top of the /// operating system. In many configurations, this field is omitted, and the /// environment is implied by the operating system. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum Environment { @@ -907,6 +921,7 @@ impl Environment { /// The "binary format" field, which is usually omitted, and the binary format /// is implied by the other fields. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] #[allow(missing_docs)] pub enum BinaryFormat { diff --git a/src/triple.rs b/src/triple.rs index a8f2758..d92ea67 100644 --- a/src/triple.rs +++ b/src/triple.rs @@ -52,6 +52,7 @@ impl PointerWidth { /// The calling convention, which specifies things like which registers are /// used for passing arguments, which registers are callee-saved, and so on. +#[cfg_attr(feature = "rust_1_40", non_exhaustive)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum CallingConvention { /// "System V", which is used on most Unix-like platfoms. Note that the From 6f37eeaf58d8f6de0260cc4d7c0e23187ee69d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 13 Feb 2026 12:21:00 +0100 Subject: [PATCH 3/5] This helps only with cargo-clippy --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 3375d89..7d8856d 100644 --- a/build.rs +++ b/build.rs @@ -44,6 +44,7 @@ use self::targets::Vendor; use self::triple::Triple; fn main() { + println!("cargo:rustc-check-cfg=cfg(feature, values(\"rust_1_40\", \"cargo-clippy\"))"); let out_dir = PathBuf::from( env::var_os("OUT_DIR").expect("The OUT_DIR environment variable must be set"), ); From caead36b21f4256423c05f14890322134826d0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 13 Feb 2026 12:35:19 +0100 Subject: [PATCH 4/5] It needs to be done in Cargo.toml --- Cargo.toml | 3 +++ build.rs | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8bbf21f..b113dc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,3 +29,6 @@ arch_z80 = [] [badges] maintenance = { status = "passively-maintained" } + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(feature, values("rust_1_40", "cargo-clippy"))'] } diff --git a/build.rs b/build.rs index 7d8856d..3375d89 100644 --- a/build.rs +++ b/build.rs @@ -44,7 +44,6 @@ use self::targets::Vendor; use self::triple::Triple; fn main() { - println!("cargo:rustc-check-cfg=cfg(feature, values(\"rust_1_40\", \"cargo-clippy\"))"); let out_dir = PathBuf::from( env::var_os("OUT_DIR").expect("The OUT_DIR environment variable must be set"), ); From dba3b40d5ff53610a6244b48071f2b3acd1c3ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Fri, 13 Feb 2026 12:41:45 +0100 Subject: [PATCH 5/5] Add ZKVM OS and riscv64im Riscv64Arch --- src/targets.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/targets.rs b/src/targets.rs index c908269..a258f14 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -450,6 +450,7 @@ pub enum Riscv64Architecture { Riscv64, Riscv64gc, Riscv64imac, + Riscv64im, Riscv64a23, } @@ -462,6 +463,7 @@ impl Riscv64Architecture { Riscv64 => Cow::Borrowed("riscv64"), Riscv64gc => Cow::Borrowed("riscv64gc"), Riscv64imac => Cow::Borrowed("riscv64imac"), + Riscv64im => Cow::Borrowed("riscv64im"), Riscv64a23 => Cow::Borrowed("riscv64a23"), } } @@ -746,6 +748,7 @@ pub enum OperatingSystem { Windows, /// An alternate name for [visionOS][Self::VisionOS]. XROS(Option), + Zkvm, } impl OperatingSystem { @@ -807,6 +810,7 @@ impl OperatingSystem { WatchOS(deployment_target) => darwin_version("watchos", deployment_target), Windows => Cow::Borrowed("windows"), XROS(deployment_target) => darwin_version("xros", deployment_target), + Zkvm => Cow::Borrowed("zkvm"), } } @@ -1306,6 +1310,7 @@ impl FromStr for Riscv64Architecture { "riscv64" => Riscv64, "riscv64gc" => Riscv64gc, "riscv64imac" => Riscv64imac, + "riscv64im" => Riscv64im, "riscv64a23" => Riscv64a23, _ => return Err(()), }) @@ -1655,6 +1660,7 @@ impl FromStr for OperatingSystem { "wasip2" => WasiP2, "windows" => Windows, "espidf" => Espidf, + "zkvm" => Zkvm, _ => return Err(()), }) }