@@ -10,6 +10,8 @@ pub enum CfgExpr {
1010 All ( Vec < CfgExpr > ) ,
1111 Any ( Vec < CfgExpr > ) ,
1212 Value ( Cfg ) ,
13+ True ,
14+ False ,
1315}
1416
1517/// A cfg value.
@@ -87,6 +89,8 @@ impl CfgExpr {
8789 CfgExpr :: All ( ref e) => e. iter ( ) . all ( |e| e. matches ( cfg) ) ,
8890 CfgExpr :: Any ( ref e) => e. iter ( ) . any ( |e| e. matches ( cfg) ) ,
8991 CfgExpr :: Value ( ref e) => cfg. contains ( e) ,
92+ CfgExpr :: True => true ,
93+ CfgExpr :: False => false ,
9094 }
9195 }
9296
@@ -106,7 +110,7 @@ impl CfgExpr {
106110 }
107111 Ok ( ( ) )
108112 }
109- CfgExpr :: Value ( _) => Ok ( ( ) ) ,
113+ CfgExpr :: Value ( _) | CfgExpr :: True | CfgExpr :: False => Ok ( ( ) ) ,
110114 }
111115 }
112116
@@ -137,6 +141,8 @@ impl fmt::Display for CfgExpr {
137141 CfgExpr :: All ( ref e) => write ! ( f, "all({})" , CommaSep ( e) ) ,
138142 CfgExpr :: Any ( ref e) => write ! ( f, "any({})" , CommaSep ( e) ) ,
139143 CfgExpr :: Value ( ref e) => write ! ( f, "{}" , e) ,
144+ CfgExpr :: True => write ! ( f, "true" ) ,
145+ CfgExpr :: False => write ! ( f, "false" ) ,
140146 }
141147 }
142148}
@@ -191,7 +197,11 @@ impl<'a> Parser<'a> {
191197 self . eat ( & Token :: RightParen ) ?;
192198 Ok ( CfgExpr :: Not ( Box :: new ( e) ) )
193199 }
194- Some ( Ok ( ..) ) => self . cfg ( ) . map ( CfgExpr :: Value ) ,
200+ Some ( Ok ( ..) ) => self . cfg ( ) . map ( |v| match v {
201+ Cfg :: Name ( n) if n == "true" => CfgExpr :: True ,
202+ Cfg :: Name ( n) if n == "false" => CfgExpr :: False ,
203+ v => CfgExpr :: Value ( v) ,
204+ } ) ,
195205 Some ( Err ( ..) ) => Err ( self . t . next ( ) . unwrap ( ) . err ( ) . unwrap ( ) ) ,
196206 None => Err ( ParseError :: new (
197207 self . t . orig ,
0 commit comments