@@ -22,7 +22,6 @@ pub enum DirectoryOwnership {
2222 relative : Option < Ident > ,
2323 } ,
2424 UnownedViaBlock ,
25- UnownedViaMod ,
2625}
2726
2827/// Information about the path to a module.
@@ -134,23 +133,20 @@ fn submod_path<'a>(
134133 dir_path : & Path ,
135134) -> PResult < ' a , ModulePathSuccess > {
136135 if let Some ( path) = submod_path_from_attr ( sess, attrs, dir_path) {
137- let ownership = match path. file_name ( ) . and_then ( |s| s. to_str ( ) ) {
138- // All `#[path]` files are treated as though they are a `mod.rs` file.
139- // This means that `mod foo;` declarations inside `#[path]`-included
140- // files are siblings,
141- //
142- // Note that this will produce weirdness when a file named `foo.rs` is
143- // `#[path]` included and contains a `mod foo;` declaration.
144- // If you encounter this, it's your own darn fault :P
145- Some ( _) => DirectoryOwnership :: Owned { relative : None } ,
146- _ => DirectoryOwnership :: UnownedViaMod ,
147- } ;
136+ // All `#[path]` files are treated as though they are a `mod.rs` file.
137+ // This means that `mod foo;` declarations inside `#[path]`-included
138+ // files are siblings,
139+ //
140+ // Note that this will produce weirdness when a file named `foo.rs` is
141+ // `#[path]` included and contains a `mod foo;` declaration.
142+ // If you encounter this, it's your own darn fault :P
143+ let ownership = DirectoryOwnership :: Owned { relative : None } ;
148144 return Ok ( ModulePathSuccess { ownership, path } ) ;
149145 }
150146
151147 let relative = match ownership {
152148 DirectoryOwnership :: Owned { relative } => relative,
153- DirectoryOwnership :: UnownedViaBlock | DirectoryOwnership :: UnownedViaMod => None ,
149+ DirectoryOwnership :: UnownedViaBlock => None ,
154150 } ;
155151 let ModulePath { path_exists, name, result } =
156152 default_submod_path ( & sess. parse_sess , id, span, relative, dir_path) ;
@@ -160,10 +156,6 @@ fn submod_path<'a>(
160156 let _ = result. map_err ( |mut err| err. cancel ( ) ) ;
161157 error_decl_mod_in_block ( & sess. parse_sess , span, path_exists, & name)
162158 }
163- DirectoryOwnership :: UnownedViaMod => {
164- let _ = result. map_err ( |mut err| err. cancel ( ) ) ;
165- error_cannot_declare_mod_here ( & sess. parse_sess , span, path_exists, & name)
166- }
167159 }
168160}
169161
@@ -182,41 +174,6 @@ fn error_decl_mod_in_block<'a, T>(
182174 Err ( err)
183175}
184176
185- fn error_cannot_declare_mod_here < ' a , T > (
186- sess : & ' a ParseSess ,
187- span : Span ,
188- path_exists : bool ,
189- name : & str ,
190- ) -> PResult < ' a , T > {
191- let mut err =
192- sess. span_diagnostic . struct_span_err ( span, "cannot declare a new module at this location" ) ;
193- if !span. is_dummy ( ) {
194- if let FileName :: Real ( src_name) = sess. source_map ( ) . span_to_filename ( span) {
195- let src_path = src_name. into_local_path ( ) ;
196- if let Some ( stem) = src_path. file_stem ( ) {
197- let mut dest_path = src_path. clone ( ) ;
198- dest_path. set_file_name ( stem) ;
199- dest_path. push ( "mod.rs" ) ;
200- err. span_note (
201- span,
202- & format ! (
203- "maybe move this module `{}` to its own directory via `{}`" ,
204- src_path. display( ) ,
205- dest_path. display( )
206- ) ,
207- ) ;
208- }
209- }
210- }
211- if path_exists {
212- err. span_note (
213- span,
214- & format ! ( "... or maybe `use` the module `{}` instead of possibly redeclaring it" , name) ,
215- ) ;
216- }
217- Err ( err)
218- }
219-
220177/// Derive a submodule path from the first found `#[path = "path_string"]`.
221178/// The provided `dir_path` is joined with the `path_string`.
222179pub ( super ) fn submod_path_from_attr (
0 commit comments