@@ -399,8 +399,9 @@ 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 ( ) ;
404+ pcx. set_resolve_imports ( false ) ;
404405 let files = sources
405406 . par_iter ( )
406407 . map ( |( path, source) | {
@@ -423,29 +424,44 @@ impl SourceParser for SolParser {
423424 ) ;
424425 ( path. clone ( ) , node)
425426 } ) ;
426- let mut parsed = parsed. collect :: < Vec < _ > > ( ) ;
427+ let parsed = parsed. collect :: < Vec < _ > > ( ) ;
427428
428- // Set error on the first successful source, if any. This doesn't really have to be
429- // exact, as long as at least one source has an error set it should be enough.
430- if let Some ( Err ( diag) ) = compiler. gcx ( ) . sess . emitted_errors ( ) {
431- if let Some ( idx) = parsed
432- . iter ( )
433- . position ( |( _, node) | node. data . parse_result . is_ok ( ) )
434- . or_else ( || parsed. first ( ) . map ( |_| 0 ) )
435- {
436- let ( _, node) = & mut parsed[ idx] ;
437- node. data . parse_result = Err ( diag. to_string ( ) ) ;
438- }
429+ Ok ( parsed)
430+ } )
431+ }
432+
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| {
441+ let mut pcx = compiler. parse ( ) ;
442+ pcx. set_resolve_imports ( true ) ;
443+ pcx. force_resolve_all_imports ( ) ;
444+ } ) ;
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 ( ) ) ;
439455 }
456+ }
440457
441- for ( path, node) in & parsed {
442- if let Err ( e) = & node. data . parse_result {
443- debug ! ( "failed parsing {}: {e}" , path. display( ) ) ;
444- }
458+ for node in nodes. iter ( ) {
459+ if let Err ( e) = & node. data . parse_result {
460+ debug ! ( "failed parsing:\n {e}" ) ;
445461 }
462+ }
446463
447- Ok ( parsed)
448- } )
464+ Ok ( ( ) )
449465 }
450466}
451467
0 commit comments