@@ -129,23 +129,22 @@ impl<'a> Parser<'a> {
129
129
DirectoryOwnership :: Owned { .. } => {
130
130
paths. result . map_err ( |err| self . span_fatal_err ( id_sp, err) )
131
131
}
132
- DirectoryOwnership :: UnownedViaBlock => {
133
- let msg = "Cannot declare a non-inline module inside a block \
134
- unless it has a path attribute";
135
- let mut err = self . struct_span_err ( id_sp, msg) ;
136
- if paths. path_exists {
137
- let msg = format ! (
138
- "Maybe `use` the module `{}` instead of redeclaring it" ,
139
- paths. name
140
- ) ;
141
- err. span_note ( id_sp, & msg) ;
142
- }
143
- Err ( err)
144
- }
132
+ DirectoryOwnership :: UnownedViaBlock => self . error_decl_mod_in_block ( id_sp, paths) ,
145
133
DirectoryOwnership :: UnownedViaMod => self . error_cannot_declare_mod_here ( id_sp, paths) ,
146
134
}
147
135
}
148
136
137
+ fn error_decl_mod_in_block < T > ( & self , id_sp : Span , paths : ModulePath ) -> PResult < ' a , T > {
138
+ let msg =
139
+ "Cannot declare a non-inline module inside a block unless it has a path attribute" ;
140
+ let mut err = self . struct_span_err ( id_sp, msg) ;
141
+ if paths. path_exists {
142
+ let msg = format ! ( "Maybe `use` the module `{}` instead of redeclaring it" , paths. name) ;
143
+ err. span_note ( id_sp, & msg) ;
144
+ }
145
+ Err ( err)
146
+ }
147
+
149
148
fn error_cannot_declare_mod_here < T > ( & self , id_sp : Span , paths : ModulePath ) -> PResult < ' a , T > {
150
149
let mut err = self . struct_span_err ( id_sp, "cannot declare a new module at this location" ) ;
151
150
if !id_sp. is_dummy ( ) {
0 commit comments