@@ -399,7 +399,7 @@ impl SourceParser for SolParser {
399399 & mut self ,
400400 sources : & mut Sources ,
401401 ) -> Result < Vec < ( PathBuf , Node < Self :: ParsedSource > ) > > {
402- self . compiler_mut ( ) . enter_mut ( |compiler| {
402+ self . compiler . enter_mut ( |compiler| {
403403 let mut pcx = compiler. parse ( ) ;
404404 pcx. set_resolve_imports ( false ) ;
405405 let files = sources
@@ -424,38 +424,43 @@ impl SourceParser for SolParser {
424424 ) ;
425425 ( path. clone ( ) , node)
426426 } ) ;
427- let mut parsed = parsed. collect :: < Vec < _ > > ( ) ;
428-
429- // Set error on the first successful source, if any. This doesn't really have to be
430- // exact, as long as at least one source has an error set it should be enough.
431- if let Some ( Err ( diag) ) = compiler. gcx ( ) . sess . emitted_errors ( ) {
432- if let Some ( idx) = parsed
433- . iter ( )
434- . position ( |( _, node) | node. data . parse_result . is_ok ( ) )
435- . or_else ( || parsed. first ( ) . map ( |_| 0 ) )
436- {
437- let ( _, node) = & mut parsed[ idx] ;
438- node. data . parse_result = Err ( diag. to_string ( ) ) ;
439- }
440- }
441-
442- for ( path, node) in & parsed {
443- if let Err ( e) = & node. data . parse_result {
444- debug ! ( "failed parsing {}: {e}" , path. display( ) ) ;
445- }
446- }
427+ let parsed = parsed. collect :: < Vec < _ > > ( ) ;
447428
448429 Ok ( parsed)
449430 } )
450431 }
451432
452- fn finalize_imports ( & mut self , include_paths : & BTreeSet < PathBuf > ) -> Result < ( ) > {
453- self . compiler_mut ( ) . sess_mut ( ) . opts . include_paths . extend ( include_paths. iter ( ) . cloned ( ) ) ;
454- self . compiler_mut ( ) . enter_mut ( |compiler| {
433+ fn finalize_imports (
434+ & mut self ,
435+ nodes : & mut Vec < Node < Self :: ParsedSource > > ,
436+ include_paths : & BTreeSet < PathBuf > ,
437+ ) -> Result < ( ) > {
438+ let compiler = & mut self . compiler ;
439+ compiler. sess_mut ( ) . opts . include_paths . extend ( include_paths. iter ( ) . cloned ( ) ) ;
440+ compiler. enter_mut ( |compiler| {
455441 let mut pcx = compiler. parse ( ) ;
456442 pcx. set_resolve_imports ( true ) ;
457443 pcx. force_resolve_all_imports ( ) ;
458444 } ) ;
445+
446+ // Set error on the first successful source, if any. This doesn't really have to be
447+ // exact, as long as at least one source has an error set it should be enough.
448+ if let Some ( Err ( diag) ) = compiler. sess ( ) . emitted_errors ( ) {
449+ if let Some ( idx) = nodes
450+ . iter ( )
451+ . position ( |node| node. data . parse_result . is_ok ( ) )
452+ . or_else ( || nodes. first ( ) . map ( |_| 0 ) )
453+ {
454+ nodes[ idx] . data . parse_result = Err ( diag. to_string ( ) ) ;
455+ }
456+ }
457+
458+ for node in nodes. iter ( ) {
459+ if let Err ( e) = & node. data . parse_result {
460+ debug ! ( "failed parsing:\n {e}" ) ;
461+ }
462+ }
463+
459464 Ok ( ( ) )
460465 }
461466}
0 commit comments