@@ -5291,20 +5291,29 @@ impl<'a> Parser<'a> {
5291
5291
5292
5292
/// Parse a `mod <foo> { ... }` or `mod <foo>;` item
5293
5293
fn parse_item_mod ( & mut self , outer_attrs : & [ Attribute ] ) -> PResult < ' a , ItemInfo > {
5294
- let outer_attrs = :: config:: StripUnconfigured {
5295
- config : & self . cfg ,
5296
- sess : self . sess ,
5297
- should_test : false , // irrelevant
5298
- features : None , // don't perform gated feature checking
5299
- } . process_cfg_attrs ( outer_attrs. to_owned ( ) ) ;
5294
+ let ( in_cfg, outer_attrs) = {
5295
+ let mut strip_unconfigured = :: config:: StripUnconfigured {
5296
+ config : & self . cfg ,
5297
+ sess : self . sess ,
5298
+ should_test : false , // irrelevant
5299
+ features : None , // don't perform gated feature checking
5300
+ } ;
5301
+ let outer_attrs = strip_unconfigured. process_cfg_attrs ( outer_attrs. to_owned ( ) ) ;
5302
+ ( strip_unconfigured. in_cfg ( & outer_attrs) , outer_attrs)
5303
+ } ;
5300
5304
5301
5305
let id_span = self . span ;
5302
5306
let id = self . parse_ident ( ) ?;
5303
5307
if self . check ( & token:: Semi ) {
5304
5308
self . bump ( ) ;
5305
- // This mod is in an external file. Let's go get it!
5306
- let ( m, attrs) = self . eval_src_mod ( id, & outer_attrs, id_span) ?;
5307
- Ok ( ( id, m, Some ( attrs) ) )
5309
+ if in_cfg {
5310
+ // This mod is in an external file. Let's go get it!
5311
+ let ( m, attrs) = self . eval_src_mod ( id, & outer_attrs, id_span) ?;
5312
+ Ok ( ( id, m, Some ( attrs) ) )
5313
+ } else {
5314
+ let placeholder = ast:: Mod { inner : syntax_pos:: DUMMY_SP , items : Vec :: new ( ) } ;
5315
+ Ok ( ( id, ItemKind :: Mod ( placeholder) , None ) )
5316
+ }
5308
5317
} else {
5309
5318
let directory = self . directory . clone ( ) ;
5310
5319
self . push_directory ( id, & outer_attrs) ;
0 commit comments