This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 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(
269269/// with its attributes.
270270///
271271/// This is constructed during parsing when we need to capture
272- /// tokens.
272+ /// tokens, for `cfg` and `cfg_attr` attributes .
273273///
274274/// For example, `#[cfg(FALSE)] struct Foo {}` would
275275/// have an `attrs` field containing the `#[cfg(FALSE)]` attr,
276276/// and a `tokens` field storing the (unparsed) tokens `struct Foo {}`
277+ ///
278+ /// The `cfg`/`cfg_attr` processing occurs in
279+ /// `StripUnconfigured::configure_tokens`.
277280#[ derive( Clone , Debug , Encodable , Decodable ) ]
278281pub struct AttrsTarget {
279282 /// Attributes, both outer and inner.
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ impl<'a> StripUnconfigured<'a> {
187187 . iter ( )
188188 . filter_map ( |tree| match tree. clone ( ) {
189189 AttrTokenTree :: AttrsTarget ( mut target) => {
190+ // Expand any `cfg_attr` attributes.
190191 target. attrs . flat_map_in_place ( |attr| self . process_cfg_attr ( & attr) ) ;
191192
192193 if self . in_cfg ( & target. attrs ) {
@@ -195,6 +196,8 @@ impl<'a> StripUnconfigured<'a> {
195196 ) ;
196197 Some ( AttrTokenTree :: AttrsTarget ( target) )
197198 } else {
199+ // Remove the target if there's a `cfg` attribute and
200+ // the condition isn't satisfied.
198201 None
199202 }
200203 }
You can’t perform that action at this time.
0 commit comments