@@ -40,36 +40,34 @@ impl<'a> Parser<'a> {
40
40
}
41
41
42
42
/// 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) ;
46
45
47
46
let id_span = self . token . span ;
48
47
let id = self . parse_ident ( ) ?;
49
- if self . eat ( & token:: Semi ) {
48
+ let ( module , mut inner_attrs ) = if self . eat ( & token:: Semi ) {
50
49
if in_cfg && self . recurse_into_file_modules {
51
50
// This mod is in an external file. Let's go get it!
52
51
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) ?
57
54
} 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 ( ) )
60
56
}
61
57
} else {
62
58
let old_directory = self . directory . clone ( ) ;
63
- self . push_directory ( id, & outer_attrs ) ;
59
+ self . push_directory ( id, & attrs ) ;
64
60
65
61
self . expect ( & token:: OpenDelim ( token:: Brace ) ) ?;
66
62
let mod_inner_lo = self . token . span ;
67
- let attrs = self . parse_inner_attributes ( ) ?;
63
+ let inner_attrs = self . parse_inner_attributes ( ) ?;
68
64
let module = self . parse_mod_items ( & token:: CloseDelim ( token:: Brace ) , mod_inner_lo) ?;
69
65
70
66
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 ) )
73
71
}
74
72
75
73
/// Given a termination token, parses all of the items in a module.
0 commit comments