From 8a4c5d9f8b5355ff385023e11ff7ac1555c854ff Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 7 Nov 2022 12:07:52 -0500 Subject: [PATCH] Upgrade cfg-expr to 0.12.0 To get support for parsing target_abi. See: This gets the new target_abi test to pass. --- Cargo.lock | 8 ++++---- target-spec/Cargo.toml | 2 +- target-spec/src/spec.rs | 23 ++++++++++++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab5623715060..4ad58479c985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -352,9 +352,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa" +checksum = "0bbc13bf6290a6b202cc3efb36f7ec2b739a80634215630c8053a313edf6abef" dependencies = [ "smallvec", "target-lexicon", @@ -2150,9 +2150,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" [[package]] name = "target-spec" diff --git a/target-spec/Cargo.toml b/target-spec/Cargo.toml index 38bce921b3cd..b1967e640dc7 100644 --- a/target-spec/Cargo.toml +++ b/target-spec/Cargo.toml @@ -20,7 +20,7 @@ rustdoc-args = ["--cfg=doc_cfg"] maintenance = { status = "actively-developed" } [dependencies] -cfg-expr = { version = "0.11.0", features = ["targets"] } +cfg-expr = { version = "0.12.0", features = ["targets"] } proptest = { version = "1.0.0", optional = true } serde = { version = "1.0.137", optional = true, features = ["derive"] } target-lexicon = { version = "0.12.4", features = ["std"] } diff --git a/target-spec/src/spec.rs b/target-spec/src/spec.rs index 56f095bc5588..d49132a7bfe1 100644 --- a/target-spec/src/spec.rs +++ b/target-spec/src/spec.rs @@ -149,7 +149,7 @@ impl FromStr for TargetExpression { mod tests { use super::*; use cfg_expr::{ - targets::{Family, Os}, + targets::{Abi, Arch, Family, Os}, Predicate, TargetPredicate, }; @@ -178,10 +178,23 @@ mod tests { #[test] fn test_target_abi() { - assert!(matches!( - TargetSpec::new("cfg(any(target_arch = \"wasm32\", target_abi = \"unknown\"))"), - Ok(TargetSpec::Expression(_)) - )); + let expr = + match TargetSpec::new("cfg(any(target_arch = \"wasm32\", target_abi = \"unknown\"))") + .unwrap() + { + TargetSpec::Triple(triple) => { + panic!("expected expression, got triple: {:?}", triple) + } + TargetSpec::Expression(expr) => expr, + }; + + assert_eq!( + expr.inner.predicates().collect::>(), + vec![ + Predicate::Target(TargetPredicate::Arch(Arch("wasm32".into()))), + Predicate::Target(TargetPredicate::Abi(Abi("unknown".into()))), + ], + ); } #[test]