@@ -40,36 +40,34 @@ impl<'a> Parser<'a> {
4040 }
4141
4242 /// Parses a `mod <foo> { ... }` or `mod <foo>;` item.
43- pub ( super ) fn parse_item_mod ( & mut self , outer_attrs : & [ Attribute ] ) -> PResult < ' a , ItemInfo > {
44- let ( in_cfg, outer_attrs) =
45- crate :: config:: process_configure_mod ( self . sess , self . cfg_mods , outer_attrs) ;
43+ pub ( super ) fn parse_item_mod ( & mut self , attrs : & mut Vec < Attribute > ) -> PResult < ' a , ItemInfo > {
44+ let in_cfg = crate :: config:: process_configure_mod ( self . sess , self . cfg_mods , attrs) ;
4645
4746 let id_span = self . token . span ;
4847 let id = self . parse_ident ( ) ?;
49- if self . eat ( & token:: Semi ) {
48+ let ( module , mut inner_attrs ) = if self . eat ( & token:: Semi ) {
5049 if in_cfg && self . recurse_into_file_modules {
5150 // This mod is in an external file. Let's go get it!
5251 let ModulePathSuccess { path, directory_ownership } =
53- self . submod_path ( id, & outer_attrs, id_span) ?;
54- let ( module, attrs) =
55- self . eval_src_mod ( path, directory_ownership, id. to_string ( ) , id_span) ?;
56- Ok ( ( id, ItemKind :: Mod ( module) , Some ( attrs) ) )
52+ self . submod_path ( id, & attrs, id_span) ?;
53+ self . eval_src_mod ( path, directory_ownership, id. to_string ( ) , id_span) ?
5754 } else {
58- let placeholder = ast:: Mod { inner : DUMMY_SP , items : Vec :: new ( ) , inline : false } ;
59- Ok ( ( id, ItemKind :: Mod ( placeholder) , None ) )
55+ ( ast:: Mod { inner : DUMMY_SP , items : Vec :: new ( ) , inline : false } , Vec :: new ( ) )
6056 }
6157 } else {
6258 let old_directory = self . directory . clone ( ) ;
63- self . push_directory ( id, & outer_attrs ) ;
59+ self . push_directory ( id, & attrs ) ;
6460
6561 self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
6662 let mod_inner_lo = self . token . span ;
67- let attrs = self . parse_inner_attributes ( ) ?;
63+ let inner_attrs = self . parse_inner_attributes ( ) ?;
6864 let module = self . parse_mod_items ( & token:: CloseDelim ( token:: Brace ) , mod_inner_lo) ?;
6965
7066 self . directory = old_directory;
71- Ok ( ( id, ItemKind :: Mod ( module) , Some ( attrs) ) )
72- }
67+ ( module, inner_attrs)
68+ } ;
69+ attrs. append ( & mut inner_attrs) ;
70+ Ok ( ( id, ItemKind :: Mod ( module) , None ) )
7371 }
7472
7573 /// Given a termination token, parses all of the items in a module.
0 commit comments