@@ -13,7 +13,9 @@ use crate::config::FileName;
1313use crate :: formatting:: {
1414 attr:: MetaVisitor ,
1515 items:: is_mod_decl,
16- syntux:: parser:: { Directory , DirectoryOwnership , ModulePathSuccess , Parser , ParserError } ,
16+ syntux:: parser:: {
17+ Directory , DirectoryOwnership , ModError , ModulePathSuccess , Parser , ParserError ,
18+ } ,
1719 syntux:: session:: ParseSess ,
1820 utils:: contains_skip,
1921} ;
@@ -104,6 +106,9 @@ impl<'a> AstLike for Module<'a> {
104106 fn visit_attrs ( & mut self , f : impl FnOnce ( & mut Vec < ast:: Attribute > ) ) {
105107 f ( & mut self . inner_attr )
106108 }
109+ fn tokens_mut ( & mut self ) -> Option < & mut Option < rustc_ast:: tokenstream:: LazyTokenStream > > {
110+ unimplemented ! ( )
111+ }
107112}
108113
109114/// Maps each module to the corresponding file.
@@ -371,7 +376,7 @@ impl<'ast, 'sess> ModResolver<'ast, 'sess> {
371376 ) -> Result < Option < SubModKind < ' ast > > , ModuleResolutionError > {
372377 let relative = match self . directory . ownership {
373378 DirectoryOwnership :: Owned { relative } => relative,
374- DirectoryOwnership :: UnownedViaBlock | DirectoryOwnership :: UnownedViaMod => None ,
379+ DirectoryOwnership :: UnownedViaBlock => None ,
375380 } ;
376381 if let Some ( path) =
377382 Parser :: submod_path_from_attr ( sub_mod. outer_attrs ( ) , & self . directory . path )
@@ -412,34 +417,35 @@ impl<'ast, 'sess> ModResolver<'ast, 'sess> {
412417 match self
413418 . parse_sess
414419 . default_submod_path ( sub_mod. ident ( ) , relative, & self . directory . path )
415- . result
416420 {
417421 Ok ( ModulePathSuccess {
418- path, ownership, ..
422+ file_path,
423+ dir_ownership,
424+ ..
419425 } ) => {
420426 let outside_mods_empty = mods_outside_ast. is_empty ( ) ;
421427 let should_insert = !mods_outside_ast
422428 . iter ( )
423- . any ( |( outside_path, _, _) | outside_path == & path ) ;
424- if self . parse_sess . is_file_parsed ( & path ) {
429+ . any ( |( outside_path, _, _) | outside_path == & file_path ) ;
430+ if self . parse_sess . is_file_parsed ( & file_path ) {
425431 if outside_mods_empty {
426432 return Ok ( None ) ;
427433 } else {
428434 if should_insert {
429- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
435+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
430436 }
431437 return Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) ) ;
432438 }
433439 }
434440 match Parser :: parse_file_as_module (
435441 self . parse_sess ,
436- & path ,
442+ & file_path ,
437443 sub_mod. outside_ast_mod_span ( ) ,
438444 ) {
439445 Ok ( ( attrs, items, span) ) if outside_mods_empty => {
440446 Ok ( Some ( SubModKind :: External (
441- path ,
442- ownership ,
447+ file_path ,
448+ dir_ownership ,
443449 Module :: new (
444450 span,
445451 Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
@@ -451,8 +457,8 @@ impl<'ast, 'sess> ModResolver<'ast, 'sess> {
451457 }
452458 Ok ( ( attrs, items, span) ) => {
453459 mods_outside_ast. push ( (
454- path . clone ( ) ,
455- ownership ,
460+ file_path . clone ( ) ,
461+ dir_ownership ,
456462 Module :: new (
457463 span,
458464 Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
@@ -462,39 +468,38 @@ impl<'ast, 'sess> ModResolver<'ast, 'sess> {
462468 ) ,
463469 ) ) ;
464470 if should_insert {
465- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
471+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
466472 }
467473 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
468474 }
469475 Err ( ParserError :: ParseError ) => Err ( ModuleResolutionError {
470476 module : sub_mod. name ( ) ,
471- kind : ModuleResolutionErrorKind :: ParseError { file : path } ,
477+ kind : ModuleResolutionErrorKind :: ParseError { file : file_path } ,
472478 } ) ,
473479 Err ( ..) if outside_mods_empty => Err ( ModuleResolutionError {
474480 module : sub_mod. name ( ) ,
475- kind : ModuleResolutionErrorKind :: NotFound { file : path } ,
481+ kind : ModuleResolutionErrorKind :: NotFound { file : file_path } ,
476482 } ) ,
477483 Err ( ..) => {
478484 if should_insert {
479- mods_outside_ast. push ( ( path , ownership , sub_mod. clone ( ) ) ) ;
485+ mods_outside_ast. push ( ( file_path , dir_ownership , sub_mod. clone ( ) ) ) ;
480486 }
481487 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
482488 }
483489 }
484490 }
485- Err ( mut e) if !mods_outside_ast. is_empty ( ) => {
486- e. cancel ( ) ;
491+ Err ( mod_err) if !mods_outside_ast. is_empty ( ) => {
492+ if let ModError :: ParserError ( mut e) = mod_err {
493+ e. cancel ( ) ;
494+ }
487495 Ok ( Some ( SubModKind :: MultiExternal ( mods_outside_ast) ) )
488496 }
489- Err ( mut e) => {
490- e. cancel ( ) ;
491- Err ( ModuleResolutionError {
492- module : sub_mod. name ( ) ,
493- kind : ModuleResolutionErrorKind :: NotFound {
494- file : self . directory . path . clone ( ) ,
495- } ,
496- } )
497- }
497+ Err ( _) => Err ( ModuleResolutionError {
498+ module : sub_mod. name ( ) ,
499+ kind : ModuleResolutionErrorKind :: NotFound {
500+ file : self . directory . path . clone ( ) ,
501+ } ,
502+ } ) ,
498503 }
499504 }
500505
0 commit comments