From 1ba559272115818691d8e8da8794c0bab93bda95 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 12 Dec 2025 15:30:46 +0100 Subject: [PATCH 1/3] Update to 1.92.0 --- README.md | 8 ++++---- src/expr.rs | 12 ++++++++++-- src/targets/builtins.rs | 30 +++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 503703b..b75d171 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ # `⚙️ cfg-expr` -**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.91.0] are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [1.92.0] are supported.** [![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI) [![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr) [![Docs](https://docs.rs/cfg-expr/badge.svg)](https://docs.rs/cfg-expr) [![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.70.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html) -[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.91.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) +[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.92.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) @@ -24,7 +24,7 @@ `cfg-expr` is a crate that can be used to parse and evaluate Rust `cfg()` expressions, both as declarable in Rust code itself, as well in cargo manifests' `[target.'cfg()'.dependencies]` sections. -It contains a list of all builtin targets known to rustc as of [1.91.0] that can be used to determine if a particular cfg expression is satisfiable. +It contains a list of all builtin targets known to rustc as of [1.92.0] that can be used to determine if a particular cfg expression is satisfiable. ```rust use cfg_expr::{targets::get_builtin_target_by_triple, Expression, Predicate}; @@ -100,4 +100,4 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[1.91.0]: (https://forge.rust-lang.org/release/platform-support.html) +[1.92.0]: (https://forge.rust-lang.org/release/platform-support.html) diff --git a/src/expr.rs b/src/expr.rs index 11dbc6c..4c690e6 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -112,6 +112,7 @@ impl TargetMatcher for target_lexicon::Triple { const NUTTX: tl::Vendor = tl::Vendor::Custom(tl::CustomVendor::Static("nuttx")); const RTEMS: tl::Vendor = tl::Vendor::Custom(tl::CustomVendor::Static("rtems")); const WALI: tl::Vendor = tl::Vendor::Custom(tl::CustomVendor::Static("wali")); + const WASIP3: tl::Vendor = tl::Vendor::Custom(tl::CustomVendor::Static("wasip3")); match tp { Abi(_) => { @@ -205,6 +206,8 @@ impl TargetMatcher for target_lexicon::Triple { | env::Sim | env::None ) + } else if env == &targ::Env::p3 { + self.vendor == WASIP3 } else { match env.0.parse::() { Ok(e) => { @@ -332,7 +335,9 @@ impl TargetMatcher for target_lexicon::Triple { false } Os(os) => { - if os == &targ::Os::wasi && matches!(self.operating_system, os::WasiP1 | os::WasiP2) + if os == &targ::Os::wasi + && (matches!(self.operating_system, os::WasiP1 | os::WasiP2) + || self.vendor == WASIP3) || (os == &targ::Os::nuttx && self.vendor == NUTTX) || (os == &targ::Os::rtems && self.vendor == RTEMS) { @@ -367,7 +372,10 @@ impl TargetMatcher for target_lexicon::Triple { Vendor(ven) => match ven.0.parse::() { Ok(v) => { if self.vendor == v - || ((self.vendor == NUTTX || self.vendor == RTEMS || self.vendor == WALI) + || ((self.vendor == NUTTX + || self.vendor == RTEMS + || self.vendor == WALI + || self.vendor == WASIP3) && ven == &targ::Vendor::unknown) { true diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index ec3b792..6ce3c52 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.91.0"; +pub(crate) const RUSTC_VERSION: &str = "1.92.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -3224,6 +3224,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("wasm32-wasip3"), + os: Some(Os::wasi), + abi: None, + arch: Arch::wasm32, + env: Some(Env::p3), + vendor: Some(Vendor::unknown), + families: Families::wasm, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("wasm32v1-none"), os: None, @@ -3653,6 +3666,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-unknown-motor"), + os: Some(Os::motor), + abi: None, + arch: Arch::x86_64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("x86_64-unknown-netbsd"), os: Some(Os::netbsd), @@ -3987,6 +4013,7 @@ impl super::Os { pub const lynxos178: Os = Os::new_const("lynxos178"); pub const macos: Os = Os::new_const("macos"); pub const managarm: Os = Os::new_const("managarm"); + pub const motor: Os = Os::new_const("motor"); pub const netbsd: Os = Os::new_const("netbsd"); pub const nto: Os = Os::new_const("nto"); pub const nuttx: Os = Os::new_const("nuttx"); @@ -4045,6 +4072,7 @@ impl super::Env { pub const ohos: Env = Env::new_const("ohos"); pub const p1: Env = Env::new_const("p1"); pub const p2: Env = Env::new_const("p2"); + pub const p3: Env = Env::new_const("p3"); pub const relibc: Env = Env::new_const("relibc"); pub const sgx: Env = Env::new_const("sgx"); pub const sim: Env = Env::new_const("sim"); From 777720035d3fd712771a2a8f54977731d5cb202c Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 12 Dec 2025 15:35:00 +0100 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a327abb..ea554f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#85](https://github.com/EmbarkStudios/cfg-expr/pull/85) updated the builtin target list to 1.92.0. + ## [0.20.4] - 2025-10-31 ### Changed - [PR#83](https://github.com/EmbarkStudios/cfg-expr/pull/83) updated the builtin target list to 1.91.0. From 64fa8ca68e762bd38799299130bb0e93bafa992f Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 12 Dec 2025 15:37:56 +0100 Subject: [PATCH 3/3] Closes: #84 --- src/expr.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/expr.rs b/src/expr.rs index 4c690e6..5b973ae 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -708,6 +708,20 @@ impl PartialEq for Expression { } } +impl std::str::FromStr for Expression { + type Err = crate::error::ParseError; + + fn from_str(s: &str) -> Result { + Expression::parse(s) + } +} + +impl std::fmt::Display for Expression { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&self.original) + } +} + /// A propositional logic used to evaluate `Expression` instances. /// /// An `Expression` consists of some predicates and the `any`, `all` and `not` operators. An