@@ -13,7 +13,7 @@ use crate::attr::MetaVisitor;
1313use crate :: config:: FileName ;
1414use crate :: items:: is_mod_decl;
1515use crate :: syntux:: parser:: {
16- Directory , DirectoryOwnership , ModulePathSuccess , Parser , ParserError ,
16+ Directory , DirectoryOwnership , ModError , ModulePathSuccess , Parser , ParserError ,
1717} ;
1818use crate :: syntux:: session:: ParseSess ;
1919use crate :: utils:: contains_skip;
@@ -61,6 +61,9 @@ impl<'a> AstLike for Module<'a> {
6161 fn visit_attrs ( & mut self , f : impl FnOnce ( & mut Vec < ast:: Attribute > ) ) {
6262 f ( & mut self . inner_attr )
6363 }
64+ fn tokens_mut ( & mut self ) -> Option < & mut Option < rustc_ast:: tokenstream:: LazyTokenStream > > {
65+ unimplemented ! ( )
66+ }
6467}
6568
6669/// Maps each module to the corresponding file.
@@ -331,7 +334,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
331334 ) -> Result < Option < SubModKind < ' c , ' ast > > , ModuleResolutionError > {
332335 let relative = match self . directory . ownership {
333336 DirectoryOwnership :: Owned { relative } => relative,
334- DirectoryOwnership :: UnownedViaBlock | DirectoryOwnership :: UnownedViaMod => None ,
337+ DirectoryOwnership :: UnownedViaBlock => None ,
335338 } ;
336339 if let Some ( path) = Parser :: submod_path_from_attr ( attrs, & self . directory . path ) {
337340 if self . parse_sess . is_file_parsed ( & path) {
@@ -366,31 +369,32 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
366369 match self
367370 . parse_sess
368371 . default_submod_path ( mod_name, relative, & self . directory . path )
369- . result
370372 {
371373 Ok ( ModulePathSuccess {
372- path, ownership, ..
374+ file_path,
375+ dir_ownership,
376+ ..
373377 } ) => {
374378 let outside_mods_empty = mods_outside_ast. is_empty ( ) ;
375379 let should_insert = !mods_outside_ast
376380 . iter ( )
377- . any ( |( outside_path, _, _) | outside_path == & path ) ;
378- if self . parse_sess . is_file_parsed ( & path ) {
381+ . any ( |( outside_path, _, _) | outside_path == & file_path ) ;
382+ if self . parse_sess . is_file_parsed ( & file_path ) {
379383 if outside_mods_empty {
380384 return Ok ( None ) ;
381385 } else {
382386 if should_insert {
383- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
387+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
384388 }
385389 return Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) ) ;
386390 }
387391 }
388- match Parser :: parse_file_as_module ( self . parse_sess , & path , sub_mod. span ) {
392+ match Parser :: parse_file_as_module ( self . parse_sess , & file_path , sub_mod. span ) {
389393 Ok ( ( ref attrs, _, _) ) if contains_skip ( attrs) => Ok ( None ) ,
390394 Ok ( ( attrs, items, span) ) if outside_mods_empty => {
391395 Ok ( Some ( SubModKind :: External (
392- path ,
393- ownership ,
396+ file_path ,
397+ dir_ownership ,
394398 Module :: new (
395399 span,
396400 Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
@@ -401,8 +405,8 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
401405 }
402406 Ok ( ( attrs, items, span) ) => {
403407 mods_outside_ast. push ( (
404- path . clone ( ) ,
405- ownership ,
408+ file_path . clone ( ) ,
409+ dir_ownership ,
406410 Module :: new (
407411 span,
408412 Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
@@ -411,39 +415,38 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
411415 ) ,
412416 ) ) ;
413417 if should_insert {
414- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
418+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
415419 }
416420 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
417421 }
418422 Err ( ParserError :: ParseError ) => Err ( ModuleResolutionError {
419423 module : mod_name. to_string ( ) ,
420- kind : ModuleResolutionErrorKind :: ParseError { file : path } ,
424+ kind : ModuleResolutionErrorKind :: ParseError { file : file_path } ,
421425 } ) ,
422426 Err ( ..) if outside_mods_empty => Err ( ModuleResolutionError {
423427 module : mod_name. to_string ( ) ,
424- kind : ModuleResolutionErrorKind :: NotFound { file : path } ,
428+ kind : ModuleResolutionErrorKind :: NotFound { file : file_path } ,
425429 } ) ,
426430 Err ( ..) => {
427431 if should_insert {
428- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
432+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
429433 }
430434 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
431435 }
432436 }
433437 }
434- Err ( mut e) if !mods_outside_ast. is_empty ( ) => {
435- e. cancel ( ) ;
438+ Err ( mod_err) if !mods_outside_ast. is_empty ( ) => {
439+ if let ModError :: ParserError ( mut e) = mod_err {
440+ e. cancel ( ) ;
441+ }
436442 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
437443 }
438- Err ( mut e) => {
439- e. cancel ( ) ;
440- Err ( ModuleResolutionError {
441- module : mod_name. to_string ( ) ,
442- kind : ModuleResolutionErrorKind :: NotFound {
443- file : self . directory . path . clone ( ) ,
444- } ,
445- } )
446- }
444+ Err ( _) => Err ( ModuleResolutionError {
445+ module : mod_name. to_string ( ) ,
446+ kind : ModuleResolutionErrorKind :: NotFound {
447+ file : self . directory . path . clone ( ) ,
448+ } ,
449+ } ) ,
447450 }
448451 }
449452
0 commit comments