@@ -10,6 +10,8 @@ pub enum CfgExpr {
10
10
All ( Vec < CfgExpr > ) ,
11
11
Any ( Vec < CfgExpr > ) ,
12
12
Value ( Cfg ) ,
13
+ True ,
14
+ False ,
13
15
}
14
16
15
17
/// A cfg value.
@@ -87,6 +89,8 @@ impl CfgExpr {
87
89
CfgExpr :: All ( ref e) => e. iter ( ) . all ( |e| e. matches ( cfg) ) ,
88
90
CfgExpr :: Any ( ref e) => e. iter ( ) . any ( |e| e. matches ( cfg) ) ,
89
91
CfgExpr :: Value ( ref e) => cfg. contains ( e) ,
92
+ CfgExpr :: True => true ,
93
+ CfgExpr :: False => false ,
90
94
}
91
95
}
92
96
@@ -106,7 +110,7 @@ impl CfgExpr {
106
110
}
107
111
Ok ( ( ) )
108
112
}
109
- CfgExpr :: Value ( _) => Ok ( ( ) ) ,
113
+ CfgExpr :: Value ( _) | CfgExpr :: True | CfgExpr :: False => Ok ( ( ) ) ,
110
114
}
111
115
}
112
116
@@ -137,6 +141,8 @@ impl fmt::Display for CfgExpr {
137
141
CfgExpr :: All ( ref e) => write ! ( f, "all({})" , CommaSep ( e) ) ,
138
142
CfgExpr :: Any ( ref e) => write ! ( f, "any({})" , CommaSep ( e) ) ,
139
143
CfgExpr :: Value ( ref e) => write ! ( f, "{}" , e) ,
144
+ CfgExpr :: True => write ! ( f, "true" ) ,
145
+ CfgExpr :: False => write ! ( f, "false" ) ,
140
146
}
141
147
}
142
148
}
@@ -191,7 +197,11 @@ impl<'a> Parser<'a> {
191
197
self . eat ( & Token :: RightParen ) ?;
192
198
Ok ( CfgExpr :: Not ( Box :: new ( e) ) )
193
199
}
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
+ } ) ,
195
205
Some ( Err ( ..) ) => Err ( self . t . next ( ) . unwrap ( ) . err ( ) . unwrap ( ) ) ,
196
206
None => Err ( ParseError :: new (
197
207
self . t . orig ,
0 commit comments