@@ -35,7 +35,7 @@ pub fn generate_asts(
3535 SourceType :: SourceFile ( source_file) => {
3636 let root_package = build_state. get_package ( & build_state. root_config_name ) . unwrap ( ) ;
3737
38- let ( ast_path , iast_path , dirty) = if source_file. implementation . parse_dirty
38+ let ( ast_result , iast_result , dirty) = if source_file. implementation . parse_dirty
3939 || source_file
4040 . interface
4141 . as_ref ( )
@@ -80,18 +80,18 @@ pub fn generate_asts(
8080 )
8181 } ;
8282
83- ( module_name. to_owned ( ) , ast_path , iast_path , dirty)
83+ ( module_name. to_owned ( ) , ast_result , iast_result , dirty)
8484 }
8585 }
8686 } )
8787 . collect :: < Vec < (
8888 String ,
89- Result < ( String , Option < String > ) , String > ,
90- Result < Option < ( String , Option < String > ) > , String > ,
89+ Result < ( String , Option < helpers :: StdErr > ) , String > ,
90+ Result < Option < ( String , Option < helpers :: StdErr > ) > , String > ,
9191 bool ,
9292 ) > > ( )
9393 . into_iter ( )
94- . for_each ( |( module_name, ast_path , iast_path , is_dirty) | {
94+ . for_each ( |( module_name, ast_result , iast_result , is_dirty) | {
9595 if let Some ( module) = build_state. modules . get_mut ( & module_name) {
9696 // if the module is dirty, mark it also compile_dirty
9797 // do NOT set to false if the module is not parse_dirty, it needs to keep
@@ -104,57 +104,77 @@ pub fn generate_asts(
104104 . get ( & module. package_name )
105105 . expect ( "Package not found" ) ;
106106 if let SourceType :: SourceFile ( ref mut source_file) = module. source_type {
107- match ast_path {
108- // supress warnings in non-pinned deps
109- Ok ( ( _path, Some ( err) ) ) if package. is_pinned_dep => {
107+ // We get Err(x) when there is a parse error. When it's Ok(_, Some(
108+ // stderr_warnings )), the outputs are warnings
109+ match ast_result {
110+ // In case of a pinned (internal) dependency, we want to keep on
111+ // propagating the warning with every compile. So we mark it as dirty for
112+ // the next round
113+ Ok ( ( _path, Some ( stderr_warnings) ) ) if package. is_pinned_dep => {
110114 source_file. implementation . parse_state = ParseState :: Warning ;
111115 source_file. implementation . parse_dirty = true ;
112116 if let Some ( interface) = source_file. interface . as_mut ( ) {
113117 interface. parse_dirty = false ;
114118 }
115- logs:: append ( package, & err ) ;
116- stderr. push_str ( & err ) ;
119+ logs:: append ( package, & stderr_warnings ) ;
120+ stderr. push_str ( & stderr_warnings ) ;
117121 }
118- Ok ( ( _path, None ) ) => {
122+ Ok ( ( _path, Some ( _) ) ) | Ok ( ( _path, None ) ) => {
123+ // If we do have stderr_warnings here, the file is not a pinned
124+ // dependency (so some external dep). We can ignore those
119125 source_file. implementation . parse_state = ParseState :: Success ;
120126 source_file. implementation . parse_dirty = false ;
121127 if let Some ( interface) = source_file. interface . as_mut ( ) {
122128 interface. parse_dirty = false ;
123129 }
124130 }
125131 Err ( err) => {
132+ // Some compilation error
126133 source_file. implementation . parse_state = ParseState :: ParseError ;
127134 source_file. implementation . parse_dirty = true ;
128135 logs:: append ( package, & err) ;
129136 has_failure = true ;
130137 stderr. push_str ( & err) ;
131138 }
132- _ => ( ) ,
133139 } ;
134- }
135140
136- match ( iast_path, module. source_type . to_owned ( ) ) {
137- ( Ok ( Some ( ( _path, Some ( err) ) ) ) , SourceType :: SourceFile ( ref mut source_file) )
138- if package. is_pinned_dep =>
139- {
140- // supress warnings in non-pinned deps
141- if let Some ( interface) = source_file. interface . as_mut ( ) {
142- interface. parse_state = ParseState :: Warning ;
143- interface. parse_dirty = true ;
141+ // We get Err(x) when there is a parse error. When it's Ok(_, Some(( _path,
142+ // stderr_warnings ))), the outputs are warnings
143+ match iast_result {
144+ // In case of a pinned (internal) dependency, we want to keep on
145+ // propagating the warning with every compile. So we mark it as dirty for
146+ // the next round
147+ Ok ( Some ( ( _path, Some ( stderr_warnings) ) ) ) if package. is_pinned_dep => {
148+ if let Some ( interface) = source_file. interface . as_mut ( ) {
149+ interface. parse_state = ParseState :: Warning ;
150+ interface. parse_dirty = true ;
151+ }
152+ logs:: append ( package, & stderr_warnings) ;
153+ stderr. push_str ( & stderr_warnings) ;
144154 }
145- logs:: append ( package, & err) ;
146- stderr. push_str ( & err) ;
147- }
148- ( Err ( err) , SourceType :: SourceFile ( ref mut source_file) ) => {
149- if let Some ( interface) = source_file. interface . as_mut ( ) {
150- interface. parse_state = ParseState :: ParseError ;
151- interface. parse_dirty = true ;
155+ Ok ( Some ( ( _, None ) ) ) | Ok ( Some ( ( _, Some ( _) ) ) ) => {
156+ // If we do have stderr_warnings here, the file is not a pinned
157+ // dependency (so some external dep). We can ignore those
158+ if let Some ( interface) = source_file. interface . as_mut ( ) {
159+ interface. parse_state = ParseState :: Success ;
160+ interface. parse_dirty = false ;
161+ }
162+ }
163+ Err ( err) => {
164+ // Some compilation error
165+ if let Some ( interface) = source_file. interface . as_mut ( ) {
166+ interface. parse_state = ParseState :: ParseError ;
167+ interface. parse_dirty = true ;
168+ }
169+ logs:: append ( package, & err) ;
170+ has_failure = true ;
171+ stderr. push_str ( & err) ;
172+ }
173+ Ok ( None ) => {
174+ // The file had no interface file associated
175+ ( )
152176 }
153- logs:: append ( package, & err) ;
154- has_failure = true ;
155- stderr. push_str ( & err) ;
156177 }
157- _ => ( ) ,
158178 } ;
159179 }
160180 } ) ;
@@ -263,7 +283,7 @@ fn generate_ast(
263283 version : & str ,
264284 bsc_path : & str ,
265285 workspace_root : & Option < String > ,
266- ) -> Result < ( String , Option < String > ) , String > {
286+ ) -> Result < ( String , Option < helpers :: StdErr > ) , String > {
267287 let file_path = PathBuf :: from ( & package. path ) . join ( filename) ;
268288 let contents = helpers:: read_file ( & file_path) . expect ( "Error reading file" ) ;
269289
0 commit comments