@@ -183,6 +183,8 @@ pub struct Parser<'a> {
183
183
pub expected_tokens : Vec < TokenType > ,
184
184
pub tts : Vec < ( TokenTree , usize ) > ,
185
185
pub desugar_doc_comments : bool ,
186
+ /// Whether we should configure out of line modules as we parse.
187
+ pub cfg_mods : bool ,
186
188
}
187
189
188
190
#[ derive( PartialEq , Eq , Clone ) ]
@@ -273,6 +275,7 @@ impl<'a> Parser<'a> {
273
275
expected_tokens : Vec :: new ( ) ,
274
276
tts : if tt. len ( ) > 0 { vec ! [ ( tt, 0 ) ] } else { Vec :: new ( ) } ,
275
277
desugar_doc_comments : desugar_doc_comments,
278
+ cfg_mods : true ,
276
279
} ;
277
280
278
281
let tok = parser. next_tok ( ) ;
@@ -5210,7 +5213,7 @@ impl<'a> Parser<'a> {
5210
5213
features : None , // don't perform gated feature checking
5211
5214
} ;
5212
5215
let outer_attrs = strip_unconfigured. process_cfg_attrs ( outer_attrs. to_owned ( ) ) ;
5213
- ( strip_unconfigured. in_cfg ( & outer_attrs) , outer_attrs)
5216
+ ( ! self . cfg_mods || strip_unconfigured. in_cfg ( & outer_attrs) , outer_attrs)
5214
5217
} ;
5215
5218
5216
5219
let id_span = self . span ;
@@ -5396,6 +5399,7 @@ impl<'a> Parser<'a> {
5396
5399
5397
5400
let mut p0 =
5398
5401
new_sub_parser_from_file ( self . sess , & path, directory_ownership, Some ( name) , id_sp) ;
5402
+ p0. cfg_mods = self . cfg_mods ;
5399
5403
let mod_inner_lo = p0. span . lo ;
5400
5404
let mod_attrs = p0. parse_inner_attributes ( ) ?;
5401
5405
let m0 = p0. parse_mod_items ( & token:: Eof , mod_inner_lo) ?;
0 commit comments