File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -269,11 +269,14 @@ fn attrs_and_tokens_to_token_trees(
269
269
/// with its attributes.
270
270
///
271
271
/// This is constructed during parsing when we need to capture
272
- /// tokens.
272
+ /// tokens, for `cfg` and `cfg_attr` attributes .
273
273
///
274
274
/// For example, `#[cfg(FALSE)] struct Foo {}` would
275
275
/// have an `attrs` field containing the `#[cfg(FALSE)]` attr,
276
276
/// and a `tokens` field storing the (unparsed) tokens `struct Foo {}`
277
+ ///
278
+ /// The `cfg`/`cfg_attr` processing occurs in
279
+ /// `StripUnconfigured::configure_tokens`.
277
280
#[ derive( Clone , Debug , Encodable , Decodable ) ]
278
281
pub struct AttrsTarget {
279
282
/// Attributes, both outer and inner.
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ impl<'a> StripUnconfigured<'a> {
187
187
. iter ( )
188
188
. filter_map ( |tree| match tree. clone ( ) {
189
189
AttrTokenTree :: AttrsTarget ( mut target) => {
190
+ // Expand any `cfg_attr` attributes.
190
191
target. attrs . flat_map_in_place ( |attr| self . process_cfg_attr ( & attr) ) ;
191
192
192
193
if self . in_cfg ( & target. attrs ) {
@@ -195,6 +196,8 @@ impl<'a> StripUnconfigured<'a> {
195
196
) ;
196
197
Some ( AttrTokenTree :: AttrsTarget ( target) )
197
198
} else {
199
+ // Remove the target if there's a `cfg` attribute and
200
+ // the condition isn't satisfied.
198
201
None
199
202
}
200
203
}
You can’t perform that action at this time.
0 commit comments