diff --git a/src/expr.rs b/src/expr.rs index 2e1aa01..3d76111 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -79,7 +79,12 @@ impl TargetMatcher for targ::TargetInfo { }, Family(fam) => self.families.contains(fam), HasAtomic(has_atomic) => self.has_atomics.contains(*has_atomic), - Os(os) => Some(os) == self.os.as_ref(), + Os(os) => match &self.os { + Some(self_os) => os == self_os, + // os = "none" means it should be matched against None. Note that this is different + // from "env" above. + None => os.as_str() == "none", + }, PointerWidth(w) => *w == self.pointer_width, Vendor(ven) => match &self.vendor { Some(v) => ven == v, diff --git a/tests/eval.rs b/tests/eval.rs index a9efc17..b386840 100644 --- a/tests/eval.rs +++ b/tests/eval.rs @@ -251,6 +251,12 @@ fn complex() { // Should *not* match x86_64 windows or android assert!(!complex.eval(|pred| tg_match!(pred, windows_msvc))); assert!(!complex.eval(|pred| tg_match!(pred, android))); + + // Ensure that target_os = "none" matches against Os == None. + let complex = Expression::parse(r#"all(target_os="none")"#).unwrap(); + let armebv7r_none_eabi = Target::make("armebv7r-none-eabi"); + assert!(!complex.eval(|pred| tg_match!(pred, linux_gnu))); + assert!(complex.eval(|pred| tg_match!(pred, armebv7r_none_eabi))); } #[test]